Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
e715cc6d37 | |||
f7abc175aa |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartdata",
|
"name": "@pushrocks/smartdata",
|
||||||
"version": "3.1.9",
|
"version": "3.1.10",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartdata",
|
"name": "@pushrocks/smartdata",
|
||||||
"version": "3.1.9",
|
"version": "3.1.10",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "do more with data",
|
"description": "do more with data",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
@ -25,7 +25,7 @@ export function Collection(dbArg: SmartdataDb | TDelayedDbCreation) {
|
|||||||
// tslint:disable-next-line: no-string-literal
|
// tslint:disable-next-line: no-string-literal
|
||||||
constructor['smartdataCollection'] = new SmartdataCollection(constructor, dbArg);
|
constructor['smartdataCollection'] = new SmartdataCollection(constructor, dbArg);
|
||||||
} else {
|
} else {
|
||||||
constructor['smartdataDelayedDatabase'] = () => {
|
constructor['smartdataDelayedCollection'] = () => {
|
||||||
return new SmartdataCollection(constructor, dbArg());
|
return new SmartdataCollection(constructor, dbArg());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -81,9 +81,9 @@ export class SmartDataDbDoc<T> {
|
|||||||
// tslint:disable-next-line: no-string-literal
|
// tslint:disable-next-line: no-string-literal
|
||||||
this.collection = this.constructor['smartdataCollection'];
|
this.collection = this.constructor['smartdataCollection'];
|
||||||
// tslint:disable-next-line: no-string-literal
|
// tslint:disable-next-line: no-string-literal
|
||||||
} else if (typeof this.constructor['smartdataDelayedDatabase'] === 'function') {
|
} else if (typeof this.constructor['smartdataDelayedCollection'] === 'function') {
|
||||||
// tslint:disable-next-line: no-string-literal
|
// tslint:disable-next-line: no-string-literal
|
||||||
this.collection = this.constructor['smartdataDelayedDatabase']();
|
this.collection = this.constructor['smartdataDelayedCollection']();
|
||||||
} else {
|
} else {
|
||||||
console.error('Could not determine collection for DbDoc');
|
console.error('Could not determine collection for DbDoc');
|
||||||
}
|
}
|
||||||
@ -91,7 +91,13 @@ export class SmartDataDbDoc<T> {
|
|||||||
|
|
||||||
static async getInstances<T>(filterArg): Promise<T[]> {
|
static async getInstances<T>(filterArg): Promise<T[]> {
|
||||||
let self: any = this; // fool typesystem
|
let self: any = this; // fool typesystem
|
||||||
let referenceMongoDBCollection: SmartdataCollection<T> = self.smartdataCollection;
|
let referenceMongoDBCollection: SmartdataCollection<T>;
|
||||||
|
|
||||||
|
if (self.smartdataCollection) {
|
||||||
|
referenceMongoDBCollection = self.smartdataCollection;
|
||||||
|
} else if (self.smartdataDelayedCollection) {
|
||||||
|
referenceMongoDBCollection = self.smartdataDelayedCollection();
|
||||||
|
};
|
||||||
const foundDocs = await referenceMongoDBCollection.find(filterArg);
|
const foundDocs = await referenceMongoDBCollection.find(filterArg);
|
||||||
const returnArray = [];
|
const returnArray = [];
|
||||||
for (let item of foundDocs) {
|
for (let item of foundDocs) {
|
||||||
|
Reference in New Issue
Block a user