update module structure
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
import * as plugins from './smartdata.plugins';
|
||||
import { Objectmap } from '@pushrocks/lik';
|
||||
import { ObjectMap } from '@pushrocks/lik';
|
||||
|
||||
import { SmartdataCollection } from './smartdata.classes.collection';
|
||||
|
||||
import * as mongoHelpers from './smartdata.mongohelpers';
|
||||
import { logger } from './smartdata.logging';
|
||||
|
||||
/**
|
||||
* interface - indicates the connection status of the db
|
||||
@ -32,7 +33,7 @@ export class SmartdataDb {
|
||||
mongoDbClient: plugins.mongodb.MongoClient;
|
||||
mongoDb: plugins.mongodb.Db;
|
||||
status: TConnectionStatus;
|
||||
smartdataCollectionMap = new Objectmap<SmartdataCollection<any>>();
|
||||
smartdataCollectionMap = new ObjectMap<SmartdataCollection<any>>();
|
||||
|
||||
constructor(smartdataOptions: ISmartdataOptions) {
|
||||
this.smartdataOptions = smartdataOptions;
|
||||
@ -68,10 +69,7 @@ export class SmartdataDb {
|
||||
public async close(): Promise<any> {
|
||||
await this.mongoDbClient.close();
|
||||
this.status = 'disconnected';
|
||||
plugins.smartlog.defaultLogger.log(
|
||||
'info',
|
||||
`disconnected from database ${this.smartdataOptions.mongoDbName}`
|
||||
);
|
||||
logger.log('info', `disconnected from database ${this.smartdataOptions.mongoDbName}`);
|
||||
}
|
||||
|
||||
// handle table to class distribution
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as plugins from './smartdata.plugins';
|
||||
|
||||
import { Objectmap } from '@pushrocks/lik';
|
||||
import { ObjectMap } from '@pushrocks/lik';
|
||||
|
||||
import { SmartdataDb } from './smartdata.classes.db';
|
||||
import { SmartdataCollection } from './smartdata.classes.collection';
|
||||
@ -150,9 +150,9 @@ export class SmartDataDbDoc<T, TImplements> {
|
||||
* also store any referenced objects to DB
|
||||
* better for data consistency
|
||||
*/
|
||||
public saveDeep(savedMapArg: Objectmap<SmartDataDbDoc<any, any>> = null) {
|
||||
public saveDeep(savedMapArg: ObjectMap<SmartDataDbDoc<any, any>> = null) {
|
||||
if (!savedMapArg) {
|
||||
savedMapArg = new Objectmap<SmartDataDbDoc<any, any>>();
|
||||
savedMapArg = new ObjectMap<SmartDataDbDoc<any, any>>();
|
||||
}
|
||||
savedMapArg.add(this);
|
||||
this.save();
|
||||
|
3
ts/smartdata.logging.ts
Normal file
3
ts/smartdata.logging.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import * as plugins from './smartdata.plugins';
|
||||
|
||||
export const logger = new plugins.smartlog.ConsoleLog();
|
@ -1,3 +1,7 @@
|
||||
export const addUsername = (mongoUrlArg: string, usernameArg: string): string => {
|
||||
return mongoUrlArg.replace('<USERNAME>', usernameArg);
|
||||
};
|
||||
|
||||
export const addPassword = (mongoUrlArg: string, passwordArg: string): string => {
|
||||
return mongoUrlArg.replace('<PASSWORD>', passwordArg);
|
||||
};
|
||||
|
Reference in New Issue
Block a user