fix(core): update

This commit is contained in:
Philipp Kunz 2020-08-18 12:05:07 +00:00
parent 1e83f0a0ef
commit ffa52a5883
3 changed files with 23 additions and 28 deletions

View File

@ -15,7 +15,7 @@ import * as mongoPlugin from 'mongodb-memory-server';
// ======================================= // =======================================
let testDb: smartdata.SmartdataDb; let testDb: smartdata.SmartdataDb;
let smartdataOptions: smartdata.ISmartdataOptions; let smartdataOptions: smartdata.IMongoDescriptor;
let mongod: mongoPlugin.MongoMemoryServer; let mongod: mongoPlugin.MongoMemoryServer;
tap.test('should create a testinstance as database', async () => { tap.test('should create a testinstance as database', async () => {

View File

@ -1,5 +1,22 @@
export interface IMongoDescriptor { export interface IMongoDescriptor {
mongoDbName: string; /**
* the URL to connect to
*/
mongoDbUrl: string; 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 <PASSWORD> in the connection string
*/
mongoDbPass?: string;
} }

View File

@ -4,43 +4,21 @@ import { ObjectMap } from '@pushrocks/lik';
import { SmartdataCollection } from './smartdata.classes.collection'; import { SmartdataCollection } from './smartdata.classes.collection';
import { logger } from './smartdata.logging'; import { logger } from './smartdata.logging';
import { IMongoDescriptor } from './interfaces';
/** /**
* interface - indicates the connection status of the db * interface - indicates the connection status of the db
*/ */
export type TConnectionStatus = 'initial' | 'disconnected' | 'connected' | 'failed'; 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 <PASSWORD> in the connection string
*/
mongoDbPass?: string;
}
export class SmartdataDb { export class SmartdataDb {
smartdataOptions: ISmartdataOptions; smartdataOptions: IMongoDescriptor;
mongoDbClient: plugins.mongodb.MongoClient; mongoDbClient: plugins.mongodb.MongoClient;
mongoDb: plugins.mongodb.Db; mongoDb: plugins.mongodb.Db;
status: TConnectionStatus; status: TConnectionStatus;
smartdataCollectionMap = new ObjectMap<SmartdataCollection<any>>(); smartdataCollectionMap = new ObjectMap<SmartdataCollection<any>>();
constructor(smartdataOptions: ISmartdataOptions) { constructor(smartdataOptions: IMongoDescriptor) {
this.smartdataOptions = smartdataOptions; this.smartdataOptions = smartdataOptions;
this.status = 'initial'; this.status = 'initial';
} }