@andrewscwei/mongodb-odm
Advanced tools
Comparing version 0.18.0 to 0.19.0
@@ -75,2 +75,10 @@ /** | ||
/** | ||
* Returns an array of document IDs that match the query. | ||
* | ||
* @param query - Query for this model. | ||
* | ||
* @returns Array of matching IDs. | ||
*/ | ||
static identifyMany(query?: Query): Promise<ObjectID[]>; | ||
/** | ||
* Finds one document from this collection using the aggregation framework. If | ||
@@ -77,0 +85,0 @@ * no query is specified, a random document will be fetched. |
@@ -155,2 +155,26 @@ "use strict"; | ||
/** | ||
* Returns an array of document IDs that match the query. | ||
* | ||
* @param query - Query for this model. | ||
* | ||
* @returns Array of matching IDs. | ||
*/ | ||
static identifyMany(query) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const collection = yield this.getCollection(); | ||
const res = yield collection.aggregate([ | ||
...this.pipeline(query), | ||
{ | ||
$group: { | ||
_id: null, | ||
ids: { $addToSet: '$_id' }, | ||
}, | ||
}, | ||
]).toArray(); | ||
if (res.length === 0) | ||
return []; | ||
return res[0].ids || []; | ||
}); | ||
} | ||
/** | ||
* Finds one document from this collection using the aggregation framework. If | ||
@@ -157,0 +181,0 @@ * no query is specified, a random document will be fetched. |
{ | ||
"name": "@andrewscwei/mongodb-odm", | ||
"version": "0.18.0", | ||
"version": "0.19.0", | ||
"description": "ODM for MongoDB", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
255602
3964