@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 CHANGED
@@ -18,6 +18,7 @@ const actions = [
18
18
  "count",
19
19
  "search",
20
20
  "listActivity",
21
+ "findWithMeta",
21
22
  ];
22
23
 
23
24
  const forbiddenPipelineOperators = [
@@ -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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.69.7",
3
+ "version": "0.69.9",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {},