import { App, IMidwayApplication, Inject } from '@midwayjs/core'; import { Framework } from '@midwayjs/koa'; import { Bootstrap } from '@midwayjs/bootstrap'; import { Product } from './src/entity/product.entity'; import { WpProduct } from './src/entity/wp_product.entity'; import { Repository } from 'typeorm'; import { InjectEntityModel } from '@midwayjs/typeorm'; @App() class TestApp { @InjectEntityModel(Product) productModel: Repository; @InjectEntityModel(WpProduct) wpProductModel: Repository; async run() { if (!this.productModel || !this.wpProductModel) { console.log('Models not injected'); return; } const productCount = await this.productModel.count(); const wpProductCount = await this.wpProductModel.count(); console.log(`Product Count: ${productCount}`); console.log(`WpProduct Count: ${wpProductCount}`); } } Bootstrap.run().then(async () => { const app = await Bootstrap.getApplication() as IMidwayApplication; const testApp = await app.getApplicationContext().getAsync(TestApp); await testApp.run(); process.exit(0); });