Avoid creating a separate base db instance for graph database (#221)

* Avoid creating a separate base db instance for graph database

* Fix failing test file build

* Use getter method to get base database
This commit is contained in:
prathamesh0
2022-11-10 14:51:18 +05:30
committed by GitHub
parent ecd8b2474a
commit 8d3c68873b
40 changed files with 63 additions and 115 deletions
@@ -2,7 +2,6 @@
// Copyright 2022 Vulcanize, Inc.
//
import path from 'path';
import debug from 'debug';
import assert from 'assert';
@@ -38,7 +37,7 @@ export const handler = async (argv: any): Promise<void> => {
const db = new Database(config.database);
await db.init();
const graphDb = new GraphDatabase(config.database, path.resolve(__dirname, '../../entity/*'));
const graphDb = new GraphDatabase(db.baseDatabase);
await graphDb.init();
const graphWatcher = new GraphWatcher(graphDb, ethClient, ethProvider, config.server);
@@ -2,7 +2,6 @@
// Copyright 2022 Vulcanize, Inc.
//
import path from 'path';
import debug from 'debug';
import assert from 'assert';
@@ -34,7 +33,7 @@ export const handler = async (argv: any): Promise<void> => {
const db = new Database(config.database);
await db.init();
const graphDb = new GraphDatabase(config.database, path.resolve(__dirname, '../../entity/*'));
const graphDb = new GraphDatabase(db.baseDatabase);
await graphDb.init();
const graphWatcher = new GraphWatcher(graphDb, ethClient, ethProvider, config.server);
@@ -47,7 +47,7 @@ const main = async (): Promise<void> => {
const db = new Database(config.database);
await db.init();
const graphDb = new GraphDatabase(config.database, path.resolve(__dirname, '../entity/*'));
const graphDb = new GraphDatabase(db.baseDatabase);
await graphDb.init();
const graphWatcher = new GraphWatcher(graphDb, ethClient, ethProvider, config.server);
@@ -47,7 +47,7 @@ export const main = async (): Promise<any> => {
const db = new Database(config.database);
await db.init();
const graphDb = new GraphDatabase(config.database, path.resolve(__dirname, '../entity/*'));
const graphDb = new GraphDatabase(db.baseDatabase);
await graphDb.init();
const graphWatcher = new GraphWatcher(graphDb, ethClient, ethProvider, config.server);
@@ -2,7 +2,6 @@
// Copyright 2022 Vulcanize, Inc.
//
import path from 'path';
import yargs from 'yargs';
import 'reflect-metadata';
import debug from 'debug';
@@ -42,7 +41,7 @@ const main = async (): Promise<void> => {
const db = new Database(config.database);
await db.init();
const graphDb = new GraphDatabase(config.database, path.resolve(__dirname, '../entity/*'));
const graphDb = new GraphDatabase(db.baseDatabase);
await graphDb.init();
const graphWatcher = new GraphWatcher(graphDb, ethClient, ethProvider, config.server);
@@ -2,7 +2,6 @@
// Copyright 2021 Vulcanize, Inc.
//
import path from 'path';
import assert from 'assert';
import yargs from 'yargs';
import 'reflect-metadata';
@@ -43,7 +42,7 @@ const main = async (): Promise<void> => {
const db = new Database(config.database);
await db.init();
const graphDb = new GraphDatabase(config.database, path.resolve(__dirname, '../entity/*'));
const graphDb = new GraphDatabase(db.baseDatabase);
await graphDb.init();
const graphWatcher = new GraphWatcher(graphDb, ethClient, ethProvider, config.server);
@@ -2,9 +2,7 @@
// Copyright 2021 Vulcanize, Inc.
//
import path from 'path';
import debug from 'debug';
import { MoreThan } from 'typeorm';
import assert from 'assert';
import { getConfig, initClients, resetJobs, JobQueue } from '@cerc-io/util';
@@ -12,13 +10,6 @@ import { GraphWatcher, Database as GraphDatabase } from '@cerc-io/graph-node';
import { Database } from '../../database';
import { Indexer } from '../../indexer';
import { BlockProgress } from '../../entity/BlockProgress';
import { GetMethod } from '../../entity/GetMethod';
import { _Test } from '../../entity/_Test';
import { Author } from '../../entity/Author';
import { Blog } from '../../entity/Blog';
import { Category } from '../../entity/Category';
const log = debug('vulcanize:reset-watcher');
@@ -41,7 +32,7 @@ export const handler = async (argv: any): Promise<void> => {
const db = new Database(config.database);
await db.init();
const graphDb = new GraphDatabase(config.database, path.resolve(__dirname, '../../entity/*'));
const graphDb = new GraphDatabase(db.baseDatabase);
await graphDb.init();
const graphWatcher = new GraphWatcher(graphDb, ethClient, ethProvider, config.server);
@@ -2,7 +2,6 @@
// Copyright 2021 Vulcanize, Inc.
//
import path from 'path';
import yargs from 'yargs';
import 'reflect-metadata';
import debug from 'debug';
@@ -59,7 +58,7 @@ const main = async (): Promise<void> => {
const db = new Database(config.database);
await db.init();
const graphDb = new GraphDatabase(config.database, path.resolve(__dirname, '../entity/*'));
const graphDb = new GraphDatabase(db.baseDatabase);
await graphDb.init();
const graphWatcher = new GraphWatcher(graphDb, ethClient, ethProvider, config.server);
@@ -36,6 +36,10 @@ export class Database implements DatabaseInterface {
this._propColMaps = {};
}
get baseDatabase (): BaseDatabase {
return this.baseDatabase;
}
async init (): Promise<void> {
this._conn = await this._baseDatabase.init();
this._setPropColMaps();
+1 -2
View File
@@ -2,7 +2,6 @@
// Copyright 2021 Vulcanize, Inc.
//
import path from 'path';
import assert from 'assert';
import 'reflect-metadata';
import yargs from 'yargs';
@@ -60,7 +59,7 @@ export const main = async (): Promise<any> => {
const db = new Database(config.database);
await db.init();
const graphDb = new GraphDatabase(config.database, path.resolve(__dirname, 'entity/*'));
const graphDb = new GraphDatabase(db.baseDatabase);
await graphDb.init();
const graphWatcher = new GraphWatcher(graphDb, ethClient, ethProvider, config.server);
@@ -2,7 +2,6 @@
// Copyright 2021 Vulcanize, Inc.
//
import path from 'path';
import assert from 'assert';
import 'reflect-metadata';
import yargs from 'yargs';
@@ -95,7 +94,7 @@ export const main = async (): Promise<any> => {
const db = new Database(config.database);
await db.init();
const graphDb = new GraphDatabase(config.database, path.resolve(__dirname, 'entity/*'));
const graphDb = new GraphDatabase(db.baseDatabase);
await graphDb.init();
const graphWatcher = new GraphWatcher(graphDb, ethClient, ethProvider, config.server);
+1 -1
View File
@@ -43,7 +43,7 @@ export const main = async (): Promise<any> => {
const db = new Database(config.database);
await db.init();
const graphDb = new GraphDatabase(config.database, path.resolve(__dirname, 'entity/*'));
const graphDb = new GraphDatabase(db.baseDatabase);
await graphDb.init();
const graphWatcher = new GraphWatcher(graphDb, ethClient, ethProvider, config.server);