import mongoose from "mongoose"; import OB,{AnyBoolean} from "@onebro/oba-common"; import OBACore,{coreConfig} from "@onebro/oba-core"; export interface CCTXPlaygroundApiModelsTestSuite { api:OBACore; refresh:(dropDb?:AnyBoolean) => Promise; } export class CCTXPlaygroundApiModelsTestSuite { refresh = async (dropDb?:AnyBoolean) => { try{ const c = coreConfig(); if(c.db && dropDb){ OB.log(`dropping MongoDB database`); const {uri,opts} = c.db; if(OB.match(/mongodb\+srv/,uri)) return; const db = mongoose.createConnection(uri,opts); await db.dropDatabase(); } this.api = new OBACore(c); await this.api.init(1); } catch(e){console.error(e);throw e;} }; }