@aeriajs/core 0.0.242 → 0.0.244
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.
|
@@ -81,4 +81,4 @@ export declare const applyPreset: (entry: Partial<Description> | Description["pr
|
|
|
81
81
|
});
|
|
82
82
|
export declare const preloadDescription: <Options extends PreloadOptions, Return = Options extends {
|
|
83
83
|
serialize: true;
|
|
84
|
-
} ? Buffer
|
|
84
|
+
} ? Buffer : Description>(originalDescription: Partial<Description>, options?: Options) => Promise<Return>;
|
|
@@ -205,7 +205,12 @@ const recurseSetStage = (reference, path, parentElem, options = {
|
|
|
205
205
|
newElem = {
|
|
206
206
|
$arrayElemAt: [
|
|
207
207
|
`$${getTempName(path.slice(0, -1))}.${refName}`,
|
|
208
|
-
|
|
208
|
+
{
|
|
209
|
+
$indexOfArray: [
|
|
210
|
+
`$${getTempName(path.slice(0, -1))}._id`,
|
|
211
|
+
parentElem,
|
|
212
|
+
],
|
|
213
|
+
},
|
|
209
214
|
],
|
|
210
215
|
};
|
|
211
216
|
}
|
|
@@ -317,7 +322,7 @@ const buildLookupPipeline = (refMap, options = {}) => {
|
|
|
317
322
|
const tempName = getTempName(newPath);
|
|
318
323
|
const lookupPipeline = [];
|
|
319
324
|
tempNames.unshift(tempName);
|
|
320
|
-
if (reference.populate && reference.populate.length > 0) {
|
|
325
|
+
if (reference.populate && reference.populate.length > 0 && !reference.isInline) {
|
|
321
326
|
lookupPipeline.push({
|
|
322
327
|
$project: Object.fromEntries(reference.populate.map((index) => [
|
|
323
328
|
index,
|
|
@@ -330,10 +335,19 @@ const buildLookupPipeline = (refMap, options = {}) => {
|
|
|
330
335
|
localField = `${getTempName(path)}.${refName}`;
|
|
331
336
|
}
|
|
332
337
|
else {
|
|
333
|
-
|
|
338
|
+
let separator = '_';
|
|
334
339
|
localField = path[0] && path[0][1]
|
|
335
|
-
?
|
|
336
|
-
:
|
|
340
|
+
? '_'
|
|
341
|
+
: '';
|
|
342
|
+
for (let i = 0; i < newPath.length; i++) {
|
|
343
|
+
localField += newPath[i][0];
|
|
344
|
+
if (newPath[i + 1]) {
|
|
345
|
+
if (!newPath[i][1] || !newPath[i + 1][1]) {
|
|
346
|
+
separator = '.';
|
|
347
|
+
}
|
|
348
|
+
localField += separator;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
337
351
|
}
|
|
338
352
|
rootPipeline.unshift({
|
|
339
353
|
$lookup: {
|
|
@@ -194,7 +194,12 @@ export const recurseSetStage = (reference, path, parentElem, options = {
|
|
|
194
194
|
newElem = {
|
|
195
195
|
$arrayElemAt: [
|
|
196
196
|
`$${getTempName(path.slice(0, -1))}.${refName}`,
|
|
197
|
-
|
|
197
|
+
{
|
|
198
|
+
$indexOfArray: [
|
|
199
|
+
`$${getTempName(path.slice(0, -1))}._id`,
|
|
200
|
+
parentElem
|
|
201
|
+
]
|
|
202
|
+
}
|
|
198
203
|
]
|
|
199
204
|
};
|
|
200
205
|
} else {
|
|
@@ -305,7 +310,7 @@ export const buildLookupPipeline = (refMap, options = {}) => {
|
|
|
305
310
|
const tempName = getTempName(newPath);
|
|
306
311
|
const lookupPipeline = [];
|
|
307
312
|
tempNames.unshift(tempName);
|
|
308
|
-
if (reference.populate && reference.populate.length > 0) {
|
|
313
|
+
if (reference.populate && reference.populate.length > 0 && !reference.isInline) {
|
|
309
314
|
lookupPipeline.push({
|
|
310
315
|
$project: Object.fromEntries(reference.populate.map((index) => [
|
|
311
316
|
index,
|
|
@@ -317,8 +322,17 @@ export const buildLookupPipeline = (refMap, options = {}) => {
|
|
|
317
322
|
if (reference.isRecursive) {
|
|
318
323
|
localField = `${getTempName(path)}.${refName}`;
|
|
319
324
|
} else {
|
|
320
|
-
|
|
321
|
-
localField = path[0] && path[0][1] ?
|
|
325
|
+
let separator = "_";
|
|
326
|
+
localField = path[0] && path[0][1] ? "_" : "";
|
|
327
|
+
for (let i = 0; i < newPath.length; i++) {
|
|
328
|
+
localField += newPath[i][0];
|
|
329
|
+
if (newPath[i + 1]) {
|
|
330
|
+
if (!newPath[i][1] || !newPath[i + 1][1]) {
|
|
331
|
+
separator = ".";
|
|
332
|
+
}
|
|
333
|
+
localField += separator;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
322
336
|
}
|
|
323
337
|
rootPipeline.unshift({
|
|
324
338
|
$lookup: {
|
|
@@ -11,8 +11,7 @@ const internalRemoveAll = async (payload, context) => {
|
|
|
11
11
|
context,
|
|
12
12
|
}));
|
|
13
13
|
const it = context.collection.model.find(filters);
|
|
14
|
-
|
|
15
|
-
while (doc = await it.next()) {
|
|
14
|
+
for await (const doc of it) {
|
|
16
15
|
await (0, index_js_1.cascadingRemove)(doc, context);
|
|
17
16
|
}
|
|
18
17
|
return types_1.Result.result(await context.collection.model.deleteMany(filters));
|
|
@@ -9,8 +9,7 @@ const internalRemoveAll = async (payload, context) => {
|
|
|
9
9
|
context
|
|
10
10
|
}));
|
|
11
11
|
const it = context.collection.model.find(filters);
|
|
12
|
-
|
|
13
|
-
while (doc = await it.next()) {
|
|
12
|
+
for await (const doc of it) {
|
|
14
13
|
await cascadingRemove(doc, context);
|
|
15
14
|
}
|
|
16
15
|
return Result.result(await context.collection.model.deleteMany(filters));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.244",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"aeriaMain": "tests/fixtures/aeriaMain.js",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"mongodb-memory-server": "^9.2.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@aeriajs/builtins": "^0.0.
|
|
45
|
+
"@aeriajs/builtins": "^0.0.244",
|
|
46
46
|
"@aeriajs/common": "^0.0.136",
|
|
47
47
|
"@aeriajs/entrypoint": "^0.0.140",
|
|
48
48
|
"@aeriajs/http": "^0.0.164",
|
|
49
|
-
"@aeriajs/security": "^0.0.
|
|
49
|
+
"@aeriajs/security": "^0.0.244",
|
|
50
50
|
"@aeriajs/types": "^0.0.118",
|
|
51
51
|
"@aeriajs/validation": "^0.0.152"
|
|
52
52
|
},
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"test": "vitest run",
|
|
62
|
+
"test:typecheck": "tsc -p tsconfig.test.json",
|
|
62
63
|
"lint": "eslint .",
|
|
63
64
|
"lint:fix": "eslint . --fix",
|
|
64
65
|
"build": "pnpm build:cjs && pnpm build:esm",
|