@objectstack/driver-memory 9.0.0 → 9.1.0
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/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -180,7 +180,7 @@ declare class InMemoryDriver implements IDataDriver {
|
|
|
180
180
|
* { $group: { _id: null, avgPrice: { $avg: '$price' } } }
|
|
181
181
|
* ]);
|
|
182
182
|
*/
|
|
183
|
-
aggregate(object: string, pipeline: Record<string, any>[], options?: DriverOptions): Promise<any[]>;
|
|
183
|
+
aggregate(object: string, pipeline: Record<string, any>[] | QueryAST, options?: DriverOptions): Promise<any[]>;
|
|
184
184
|
/**
|
|
185
185
|
* Convert ObjectQL filter format to MongoDB query format for Mingo.
|
|
186
186
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -180,7 +180,7 @@ declare class InMemoryDriver implements IDataDriver {
|
|
|
180
180
|
* { $group: { _id: null, avgPrice: { $avg: '$price' } } }
|
|
181
181
|
* ]);
|
|
182
182
|
*/
|
|
183
|
-
aggregate(object: string, pipeline: Record<string, any>[], options?: DriverOptions): Promise<any[]>;
|
|
183
|
+
aggregate(object: string, pipeline: Record<string, any>[] | QueryAST, options?: DriverOptions): Promise<any[]>;
|
|
184
184
|
/**
|
|
185
185
|
* Convert ObjectQL filter format to MongoDB query format for Mingo.
|
|
186
186
|
*
|
package/dist/index.js
CHANGED
|
@@ -657,6 +657,22 @@ var _InMemoryDriver = class _InMemoryDriver {
|
|
|
657
657
|
* ]);
|
|
658
658
|
*/
|
|
659
659
|
async aggregate(object, pipeline, options) {
|
|
660
|
+
if (!Array.isArray(pipeline)) {
|
|
661
|
+
const query = pipeline;
|
|
662
|
+
this.logger.debug("Aggregate operation (QueryAST)", {
|
|
663
|
+
object,
|
|
664
|
+
groupBy: query.groupBy,
|
|
665
|
+
aggregations: query.aggregations?.length ?? 0
|
|
666
|
+
});
|
|
667
|
+
let results2 = this.getTable(object).map((r) => ({ ...r }));
|
|
668
|
+
if (query.where) {
|
|
669
|
+
const mongoQuery = this.convertToMongoQuery(query.where);
|
|
670
|
+
if (mongoQuery && Object.keys(mongoQuery).length > 0) {
|
|
671
|
+
results2 = new import_mingo.Query(mongoQuery).find(results2).all();
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
return this.performAggregation(results2, query);
|
|
675
|
+
}
|
|
660
676
|
this.logger.debug("Aggregate operation", { object, stageCount: pipeline.length });
|
|
661
677
|
const records = this.getTable(object).map((r) => ({ ...r }));
|
|
662
678
|
const aggregator = new import_mingo.Aggregator(pipeline);
|