diff --git a/test/test.ts b/test/test.ts index 7e36a25..6b11ea9 100644 --- a/test/test.ts +++ b/test/test.ts @@ -15,7 +15,7 @@ import * as mongoPlugin from 'mongodb-memory-server'; // ======================================= let testDb: smartdata.SmartdataDb; -let smartdataOptions: smartdata.ISmartdataOptions; +let smartdataOptions: smartdata.IMongoDescriptor; let mongod: mongoPlugin.MongoMemoryServer; tap.test('should create a testinstance as database', async () => { diff --git a/ts/interfaces/mongodescriptor.ts b/ts/interfaces/mongodescriptor.ts index 080f2b0..ccb6dc5 100644 --- a/ts/interfaces/mongodescriptor.ts +++ b/ts/interfaces/mongodescriptor.ts @@ -1,5 +1,22 @@ export interface IMongoDescriptor { - mongoDbName: string; + /** + * the URL to connect to + */ mongoDbUrl: string; - mongoDbPass: string; + + /** + * the db to use for the project + */ + mongoDbName?: string; + + /** + * a username to use to connect to the database + */ + + mongoDbUser?: string; + + /** + * an optional password that will be replace in the connection string + */ + mongoDbPass?: string; } diff --git a/ts/smartdata.classes.db.ts b/ts/smartdata.classes.db.ts index 9cbe7db..7f8d3ce 100644 --- a/ts/smartdata.classes.db.ts +++ b/ts/smartdata.classes.db.ts @@ -4,43 +4,21 @@ import { ObjectMap } from '@pushrocks/lik'; import { SmartdataCollection } from './smartdata.classes.collection'; import { logger } from './smartdata.logging'; +import { IMongoDescriptor } from './interfaces'; /** * interface - indicates the connection status of the db */ export type TConnectionStatus = 'initial' | 'disconnected' | 'connected' | 'failed'; -export interface ISmartdataOptions { - /** - * the URL to connect to - */ - mongoDbUrl: string; - - /** - * the db to use for the project - */ - mongoDbName?: string; - - /** - * a username to use to connect to the database - */ - - mongoDbUser?: string; - - /** - * an optional password that will be replace in the connection string - */ - mongoDbPass?: string; -} - export class SmartdataDb { - smartdataOptions: ISmartdataOptions; + smartdataOptions: IMongoDescriptor; mongoDbClient: plugins.mongodb.MongoClient; mongoDb: plugins.mongodb.Db; status: TConnectionStatus; smartdataCollectionMap = new ObjectMap>(); - constructor(smartdataOptions: ISmartdataOptions) { + constructor(smartdataOptions: IMongoDescriptor) { this.smartdataOptions = smartdataOptions; this.status = 'initial'; }