mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-02-03 08:42:50 +00:00
nikugogoi
b66dcb4af9
* Move graph-database from graph-node to util * Refactor and remove graph-node dependency from cli package * Modify dependencies using depcheck * Implement CLI refactoring changes in other watchers * Review changes to remove eden comment and fix local import in util * Import GraphDatabase from util instead of graph-node * Move graph-node non assemblyscript code to util package * Implement CLI refactoring changes in codegen * Fix graph-node tests after refactoring * Move fromStateEntityValues to graph state utils
22 lines
761 B
Handlebars
22 lines
761 B
Handlebars
//
|
|
// Copyright 2022 Vulcanize, Inc.
|
|
//
|
|
|
|
import { EventSubscriber, EntitySubscriberInterface, InsertEvent, UpdateEvent } from 'typeorm';
|
|
|
|
import { afterEntityInsertOrUpdate } from '@cerc-io/util';
|
|
|
|
import { FrothyEntity } from './FrothyEntity';
|
|
import { ENTITY_TO_LATEST_ENTITY_MAP, SUBGRAPH_ENTITIES } from '../database';
|
|
|
|
@EventSubscriber()
|
|
export class EntitySubscriber implements EntitySubscriberInterface {
|
|
async afterInsert (event: InsertEvent<any>): Promise<void> {
|
|
await afterEntityInsertOrUpdate(FrothyEntity, SUBGRAPH_ENTITIES, event, ENTITY_TO_LATEST_ENTITY_MAP);
|
|
}
|
|
|
|
async afterUpdate (event: UpdateEvent<any>): Promise<void> {
|
|
await afterEntityInsertOrUpdate(FrothyEntity, SUBGRAPH_ENTITIES, event, ENTITY_TO_LATEST_ENTITY_MAP);
|
|
}
|
|
}
|