fix(structure): format
This commit is contained in:
@ -2,4 +2,4 @@ export * from './smartdata.classes.db';
|
||||
export * from './smartdata.classes.collection';
|
||||
export * from './smartdata.classes.doc';
|
||||
|
||||
export { IMongoDescriptor } from './interfaces';
|
||||
export { IMongoDescriptor } from './interfaces';
|
||||
|
@ -1 +1 @@
|
||||
export * from './mongodescriptor';
|
||||
export * from './mongodescriptor';
|
||||
|
@ -26,10 +26,9 @@ export function Collection(dbArg: SmartdataDb | TDelayedDbCreation) {
|
||||
constructor['smartdataCollection'] = new SmartdataCollection(constructor, dbArg);
|
||||
} else {
|
||||
constructor['smartdataDelayedCollection'] = () => {
|
||||
return new SmartdataCollection(constructor, dbArg());
|
||||
return new SmartdataCollection(constructor, dbArg());
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@ -124,7 +123,7 @@ export class SmartdataCollection<T> {
|
||||
this.mongoDbCollection.updateOne(identifiableObject, saveableObject);
|
||||
}
|
||||
|
||||
public async delete (dbDocArg: T & SmartDataDbDoc<T>): Promise<any> {
|
||||
public async delete(dbDocArg: T & SmartDataDbDoc<T>): Promise<any> {
|
||||
await this.init();
|
||||
await this.checkDoc(dbDocArg);
|
||||
const identifiableObject = await dbDocArg.createIdentifiableObject();
|
||||
|
@ -53,12 +53,9 @@ export class SmartdataDb {
|
||||
);
|
||||
}
|
||||
console.log(finalConnectionUrl);
|
||||
this.mongoDbClient = await plugins.mongodb.MongoClient.connect(
|
||||
finalConnectionUrl,
|
||||
{
|
||||
useNewUrlParser: true
|
||||
}
|
||||
);
|
||||
this.mongoDbClient = await plugins.mongodb.MongoClient.connect(finalConnectionUrl, {
|
||||
useNewUrlParser: true
|
||||
});
|
||||
this.mongoDb = this.mongoDbClient.db(this.smartdataOptions.mongoDbName);
|
||||
this.status = 'connected';
|
||||
console.log(`Connected to database ${this.smartdataOptions.mongoDbName}`);
|
||||
|
@ -77,7 +77,7 @@ export class SmartDataDbDoc<T> {
|
||||
*/
|
||||
constructor() {
|
||||
this.name = this.constructor['name'];
|
||||
if(this.constructor['smartdataCollection']) {
|
||||
if (this.constructor['smartdataCollection']) {
|
||||
// tslint:disable-next-line: no-string-literal
|
||||
this.collection = this.constructor['smartdataCollection'];
|
||||
// tslint:disable-next-line: no-string-literal
|
||||
@ -92,12 +92,12 @@ export class SmartDataDbDoc<T> {
|
||||
static async getInstances<T>(filterArg): Promise<T[]> {
|
||||
let self: any = this; // fool typesystem
|
||||
let referenceMongoDBCollection: SmartdataCollection<T>;
|
||||
|
||||
|
||||
if (self.smartdataCollection) {
|
||||
referenceMongoDBCollection = self.smartdataCollection;
|
||||
} else if (self.smartdataDelayedCollection) {
|
||||
referenceMongoDBCollection = self.smartdataDelayedCollection();
|
||||
};
|
||||
}
|
||||
const foundDocs = await referenceMongoDBCollection.find(filterArg);
|
||||
const returnArray = [];
|
||||
for (let item of foundDocs) {
|
||||
@ -142,9 +142,7 @@ export class SmartDataDbDoc<T> {
|
||||
/**
|
||||
* deletes a document from the database
|
||||
*/
|
||||
async delete() {
|
||||
|
||||
}
|
||||
async delete() {}
|
||||
|
||||
/**
|
||||
* also store any referenced objects to DB
|
||||
|
Reference in New Issue
Block a user