@dnax/core 0.69.7 → 0.69.9
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.
- package/app/ctrl.ts +1 -0
- package/driver/mongo/rest.ts +30 -1
- package/package.json +1 -1
package/app/ctrl.ts
CHANGED
package/driver/mongo/rest.ts
CHANGED
|
@@ -347,6 +347,34 @@ class useRest {
|
|
|
347
347
|
}
|
|
348
348
|
});
|
|
349
349
|
}
|
|
350
|
+
|
|
351
|
+
async aggregateWithCursor(
|
|
352
|
+
collection: string,
|
|
353
|
+
pipeline: Array<any>,
|
|
354
|
+
options?: {
|
|
355
|
+
cleanDeep?: boolean;
|
|
356
|
+
batchSize?: number;
|
|
357
|
+
}
|
|
358
|
+
): Promise<AggregationCursor<Document>> {
|
|
359
|
+
return new Promise(async (resolve, reject) => {
|
|
360
|
+
try {
|
|
361
|
+
let col = getCollection(collection, this.#tenant_id);
|
|
362
|
+
if (!col) return fn.error(`Collection ${collection} not found`, 404);
|
|
363
|
+
if (options?.cleanDeep) {
|
|
364
|
+
pipeline = cleanDeep(pipeline) as any;
|
|
365
|
+
}
|
|
366
|
+
return await this.#tenant.database.db
|
|
367
|
+
?.collection(collection)
|
|
368
|
+
.aggregate(toBson(pipeline), {
|
|
369
|
+
allowDiskUse: true,
|
|
370
|
+
batchSize: options?.batchSize,
|
|
371
|
+
});
|
|
372
|
+
} catch (err) {
|
|
373
|
+
return reject(err);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
|
|
350
378
|
async insertOne(
|
|
351
379
|
collection: string,
|
|
352
380
|
data: object,
|
|
@@ -931,8 +959,9 @@ class useRest {
|
|
|
931
959
|
if (options?.cleanDeep) {
|
|
932
960
|
params = cleanDeep(params);
|
|
933
961
|
}
|
|
934
|
-
|
|
935
962
|
let col = getCollection(collection, this.#tenant_id);
|
|
963
|
+
if (!col)
|
|
964
|
+
return reject(new Error(`Collection ${collection} not found`));
|
|
936
965
|
|
|
937
966
|
await this.#tenant.database.db
|
|
938
967
|
?.collection(collection)
|