@atscript/db-mongo 0.1.152 → 0.1.153
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/agg.cjs +6 -4
- package/dist/agg.mjs +6 -4
- package/dist/index.cjs +376 -224
- package/dist/index.d.cts +37 -1
- package/dist/index.d.mts +37 -1
- package/dist/index.mjs +377 -225
- package/dist/{mongo-accumulator-BQBMx4GC.cjs → mongo-accumulator-BW-RNFg0.cjs} +136 -34
- package/dist/{mongo-accumulator-DYhg8usT.mjs → mongo-accumulator-DMPFOscc.mjs} +119 -35
- package/package.json +9 -9
package/dist/agg.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_mongo_accumulator = require("./mongo-accumulator-
|
|
2
|
+
const require_mongo_accumulator = require("./mongo-accumulator-BW-RNFg0.cjs");
|
|
3
3
|
let _atscript_db = require("@atscript/db");
|
|
4
|
-
let _atscript_db_agg = require("@atscript/db/agg");
|
|
5
4
|
let _uniqu_core = require("@uniqu/core");
|
|
5
|
+
let _atscript_db_agg = require("@atscript/db/agg");
|
|
6
6
|
//#region src/agg.ts
|
|
7
7
|
/**
|
|
8
8
|
* MongoDB aggregation pipeline builder.
|
|
@@ -156,7 +156,7 @@ function buildGroupedStages(query, { accumulators, searchStage, filterOptions })
|
|
|
156
156
|
}
|
|
157
157
|
const firstLast = controls.$select?.firstLast ?? [];
|
|
158
158
|
const rowOrder = controls.$select?.rowOrder ?? [];
|
|
159
|
-
if (firstLast.length > 0 && rowOrder.length > 0) pipeline.push(
|
|
159
|
+
if (firstLast.length > 0 && rowOrder.length > 0) pipeline.push(...require_mongo_accumulator.rowOrderStages(rowOrder));
|
|
160
160
|
const project = { _id: 0 };
|
|
161
161
|
for (const [field, idKey] of groupKeys) project[field] = `$_id.${idKey}`;
|
|
162
162
|
const nullWhenEmpty = (alias, nonNull) => {
|
|
@@ -212,9 +212,11 @@ function buildAggregatePipeline(query, searchStage, filterOptions) {
|
|
|
212
212
|
searchStage,
|
|
213
213
|
filterOptions
|
|
214
214
|
});
|
|
215
|
-
|
|
215
|
+
const { stages, cleanup } = require_mongo_accumulator.sortStages(controls);
|
|
216
|
+
pipeline.push(...stages);
|
|
216
217
|
if (controls.$skip) pipeline.push({ $skip: controls.$skip });
|
|
217
218
|
if (controls.$limit) pipeline.push({ $limit: controls.$limit });
|
|
219
|
+
if (cleanup) pipeline.push(cleanup);
|
|
218
220
|
return pipeline;
|
|
219
221
|
}
|
|
220
222
|
/**
|
package/dist/agg.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as orNull, i as buildMongoFilter,
|
|
1
|
+
import { d as rowOrderStages, f as sortStages, h as orNull, i as buildMongoFilter, m as notNullExpr, n as distinctCountExpr, p as exprToMongo, s as mongoFilterStages, t as buildAccumulator } from "./mongo-accumulator-DMPFOscc.mjs";
|
|
2
2
|
import { evaluateExpr } from "@atscript/db";
|
|
3
|
-
import { resolveAlias } from "@atscript/db/agg";
|
|
4
3
|
import { BUCKET_MAX_INSTANT, BUCKET_MIN_INSTANT } from "@uniqu/core";
|
|
4
|
+
import { resolveAlias } from "@atscript/db/agg";
|
|
5
5
|
//#region src/agg.ts
|
|
6
6
|
/**
|
|
7
7
|
* MongoDB aggregation pipeline builder.
|
|
@@ -155,7 +155,7 @@ function buildGroupedStages(query, { accumulators, searchStage, filterOptions })
|
|
|
155
155
|
}
|
|
156
156
|
const firstLast = controls.$select?.firstLast ?? [];
|
|
157
157
|
const rowOrder = controls.$select?.rowOrder ?? [];
|
|
158
|
-
if (firstLast.length > 0 && rowOrder.length > 0) pipeline.push(
|
|
158
|
+
if (firstLast.length > 0 && rowOrder.length > 0) pipeline.push(...rowOrderStages(rowOrder));
|
|
159
159
|
const project = { _id: 0 };
|
|
160
160
|
for (const [field, idKey] of groupKeys) project[field] = `$_id.${idKey}`;
|
|
161
161
|
const nullWhenEmpty = (alias, nonNull) => {
|
|
@@ -211,9 +211,11 @@ function buildAggregatePipeline(query, searchStage, filterOptions) {
|
|
|
211
211
|
searchStage,
|
|
212
212
|
filterOptions
|
|
213
213
|
});
|
|
214
|
-
|
|
214
|
+
const { stages, cleanup } = sortStages(controls);
|
|
215
|
+
pipeline.push(...stages);
|
|
215
216
|
if (controls.$skip) pipeline.push({ $skip: controls.$skip });
|
|
216
217
|
if (controls.$limit) pipeline.push({ $limit: controls.$limit });
|
|
218
|
+
if (cleanup) pipeline.push(cleanup);
|
|
217
219
|
return pipeline;
|
|
218
220
|
}
|
|
219
221
|
/**
|