2022-11-16 11:42:54 +00:00
|
|
|
//
|
|
|
|
// Copyright 2022 Vulcanize, Inc.
|
|
|
|
//
|
|
|
|
|
|
|
|
import { EventSubscriber, EntitySubscriberInterface, InsertEvent, UpdateEvent } from 'typeorm';
|
|
|
|
|
2022-11-25 10:24:35 +00:00
|
|
|
import { afterEntityInsertOrUpdate } from '@cerc-io/util';
|
|
|
|
|
2022-11-16 11:42:54 +00:00
|
|
|
import { FrothyEntity } from './FrothyEntity';
|
2022-11-23 12:12:25 +00:00
|
|
|
import { ENTITY_TO_LATEST_ENTITY_MAP, SUBGRAPH_ENTITIES } from '../database';
|
2022-11-16 11:42:54 +00:00
|
|
|
|
|
|
|
@EventSubscriber()
|
|
|
|
export class EntitySubscriber implements EntitySubscriberInterface {
|
|
|
|
async afterInsert (event: InsertEvent<any>): Promise<void> {
|
2022-11-23 12:12:25 +00:00
|
|
|
await afterEntityInsertOrUpdate(FrothyEntity, SUBGRAPH_ENTITIES, event, ENTITY_TO_LATEST_ENTITY_MAP);
|
2022-11-16 11:42:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async afterUpdate (event: UpdateEvent<any>): Promise<void> {
|
2022-11-23 12:12:25 +00:00
|
|
|
await afterEntityInsertOrUpdate(FrothyEntity, SUBGRAPH_ENTITIES, event, ENTITY_TO_LATEST_ENTITY_MAP);
|
2022-11-16 11:42:54 +00:00
|
|
|
}
|
|
|
|
}
|