@dnax/core 0.62.2 → 0.63.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/driver/mongo/@types.ts +4 -0
- package/driver/mongo/rest.ts +8 -4
- package/driver/mongo/utils.ts +17 -2
- package/package.json +1 -1
package/driver/mongo/@types.ts
CHANGED
package/driver/mongo/rest.ts
CHANGED
|
@@ -1258,7 +1258,9 @@ class useRest {
|
|
|
1258
1258
|
filter: object,
|
|
1259
1259
|
update: updateParams,
|
|
1260
1260
|
options?: Omit<
|
|
1261
|
-
optionCb
|
|
1261
|
+
optionCb & {
|
|
1262
|
+
upsert: boolean;
|
|
1263
|
+
},
|
|
1262
1264
|
"useHook" | "useCustomApi" | "elementAt" | "withMeta"
|
|
1263
1265
|
>
|
|
1264
1266
|
): Promise<{ docs: object[]; matchedCount: number; modifiedCount: number }> {
|
|
@@ -1305,6 +1307,7 @@ class useRest {
|
|
|
1305
1307
|
},
|
|
1306
1308
|
},
|
|
1307
1309
|
{
|
|
1310
|
+
upsert: options?.upsert ?? false,
|
|
1308
1311
|
session: this.#session ? this.#session : undefined,
|
|
1309
1312
|
}
|
|
1310
1313
|
);
|
|
@@ -1361,7 +1364,9 @@ class useRest {
|
|
|
1361
1364
|
filter: object,
|
|
1362
1365
|
update: updateParams,
|
|
1363
1366
|
options?: Omit<
|
|
1364
|
-
optionCb
|
|
1367
|
+
optionCb & {
|
|
1368
|
+
upsert: boolean;
|
|
1369
|
+
},
|
|
1365
1370
|
"useHook" | "useCustomApi" | "elementAt" | "withMeta"
|
|
1366
1371
|
>
|
|
1367
1372
|
): Promise<object | null> {
|
|
@@ -1410,9 +1415,8 @@ class useRest {
|
|
|
1410
1415
|
},
|
|
1411
1416
|
},
|
|
1412
1417
|
{
|
|
1413
|
-
upsert:
|
|
1418
|
+
upsert: options?.upsert ?? false,
|
|
1414
1419
|
returnDocument: "after",
|
|
1415
|
-
|
|
1416
1420
|
session: this.#session ? this.#session : undefined,
|
|
1417
1421
|
}
|
|
1418
1422
|
);
|
package/driver/mongo/utils.ts
CHANGED
|
@@ -54,7 +54,6 @@ function buildPipeline(params: findParam, col?: Collection | undefined | null) {
|
|
|
54
54
|
if (params?.$include?.length) {
|
|
55
55
|
params.$include.map((inc) => {
|
|
56
56
|
// AutoInclue by string
|
|
57
|
-
|
|
58
57
|
if (typeof inc === "string" && col) {
|
|
59
58
|
let field = getFieldCollection(inc, col);
|
|
60
59
|
if (field) {
|
|
@@ -66,7 +65,7 @@ function buildPipeline(params: findParam, col?: Collection | undefined | null) {
|
|
|
66
65
|
as: inc,
|
|
67
66
|
},
|
|
68
67
|
});
|
|
69
|
-
if (!field
|
|
68
|
+
if (!field?.relation?.hasMany) {
|
|
70
69
|
pipeline.push({
|
|
71
70
|
$unwind: {
|
|
72
71
|
path: `$${inc}`,
|
|
@@ -109,6 +108,15 @@ function buildPipeline(params: findParam, col?: Collection | undefined | null) {
|
|
|
109
108
|
preserveNullAndEmptyArrays: true,
|
|
110
109
|
},
|
|
111
110
|
});
|
|
111
|
+
} else {
|
|
112
|
+
if (!field?.relation?.hasMany) {
|
|
113
|
+
pipeline.push({
|
|
114
|
+
$unwind: {
|
|
115
|
+
path: `$${inc}`,
|
|
116
|
+
preserveNullAndEmptyArrays: true,
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
}
|
|
112
120
|
}
|
|
113
121
|
}
|
|
114
122
|
});
|
|
@@ -134,6 +142,13 @@ function buildPipeline(params: findParam, col?: Collection | undefined | null) {
|
|
|
134
142
|
$sample: params.$sample,
|
|
135
143
|
});
|
|
136
144
|
}
|
|
145
|
+
|
|
146
|
+
if (params?.$group?._id) {
|
|
147
|
+
pipeline.push({
|
|
148
|
+
$group: params?.$group,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
137
152
|
return pipeline || [];
|
|
138
153
|
}
|
|
139
154
|
|