cgserver 8.9.1 → 8.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -393,7 +393,7 @@ class MongoManager {
|
|
|
393
393
|
rs.rs = i_rs;
|
|
394
394
|
return rs;
|
|
395
395
|
}
|
|
396
|
-
async simpleAggregate(collection, property
|
|
396
|
+
async simpleAggregate(collection, property, where, size, random_size) {
|
|
397
397
|
this._convertWhere(where);
|
|
398
398
|
let rs = { errcode: null, list: null };
|
|
399
399
|
if (!this._mongoDb) {
|
|
@@ -404,8 +404,12 @@ class MongoManager {
|
|
|
404
404
|
try {
|
|
405
405
|
let col = this._mongoDb.collection(collection);
|
|
406
406
|
let params = [];
|
|
407
|
-
|
|
408
|
-
|
|
407
|
+
if (where) {
|
|
408
|
+
params.push({ '$match': where });
|
|
409
|
+
}
|
|
410
|
+
if (property) {
|
|
411
|
+
params.push({ '$project': property });
|
|
412
|
+
}
|
|
409
413
|
if (random_size) {
|
|
410
414
|
params.push({ '$sample': { 'size': random_size } });
|
|
411
415
|
}
|