import { IConnectionOptions } from "./Utils"; import { MongoConnection } from "./Connection"; import { ICollection, MongoCollection, MongoSchema } from "./Definitions" export class MongoAdapter extends MongoConnection { collections: typeof MongoCollection[]; constructor( options: IConnectionOptions) { super(options); } async bootstrap( collections: typeof MongoCollection[] ) { this.collections = collections; this.connect(); } async _connected() { for(let collection of this.collections) { await this.initCollection(collection); } } async initCollection(collection: typeof MongoCollection) { let schema = collection.getSchema(); schema.prepare(); schema.setConnection(this._db); // Connect the schema with this adapter. await schema.createCollection(); return true; } };