@objectstack/driver-memory 9.0.0 → 9.0.1

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.mjs CHANGED
@@ -623,6 +623,22 @@ var _InMemoryDriver = class _InMemoryDriver {
623
623
  * ]);
624
624
  */
625
625
  async aggregate(object, pipeline, options) {
626
+ if (!Array.isArray(pipeline)) {
627
+ const query = pipeline;
628
+ this.logger.debug("Aggregate operation (QueryAST)", {
629
+ object,
630
+ groupBy: query.groupBy,
631
+ aggregations: query.aggregations?.length ?? 0
632
+ });
633
+ let results2 = this.getTable(object).map((r) => ({ ...r }));
634
+ if (query.where) {
635
+ const mongoQuery = this.convertToMongoQuery(query.where);
636
+ if (mongoQuery && Object.keys(mongoQuery).length > 0) {
637
+ results2 = new Query(mongoQuery).find(results2).all();
638
+ }
639
+ }
640
+ return this.performAggregation(results2, query);
641
+ }
626
642
  this.logger.debug("Aggregate operation", { object, stageCount: pipeline.length });
627
643
  const records = this.getTable(object).map((r) => ({ ...r }));
628
644
  const aggregator = new Aggregator(pipeline);