@dnax/core 0.77.1 → 0.77.3
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/rest.ts +12 -5
- package/package.json +1 -1
package/driver/mongo/rest.ts
CHANGED
|
@@ -2070,11 +2070,7 @@ class useRest {
|
|
|
2070
2070
|
// controle updateOperations filter
|
|
2071
2071
|
for (const operation of updateOperations) {
|
|
2072
2072
|
if (!operation) return fn.error(`Operation required`, 400);
|
|
2073
|
-
|
|
2074
|
-
!operation.hasOwnProperty("updateOne") ||
|
|
2075
|
-
!operation.hasOwnProperty("updateMany")
|
|
2076
|
-
)
|
|
2077
|
-
return fn.error(`Only updateOne or updateMany are allowed`, 400);
|
|
2073
|
+
|
|
2078
2074
|
if (operation?.updateOne) {
|
|
2079
2075
|
if (!operation.updateOne?.filter) {
|
|
2080
2076
|
return fn.error(`Filter required`, 400);
|
|
@@ -2085,12 +2081,23 @@ class useRest {
|
|
|
2085
2081
|
return fn.error(`Filter required`, 400);
|
|
2086
2082
|
}
|
|
2087
2083
|
}
|
|
2084
|
+
|
|
2085
|
+
// obtenir toutes les keys de operation
|
|
2086
|
+
let keys = Object.keys(operation);
|
|
2087
|
+
|
|
2088
|
+
// controle si les keys sont valides
|
|
2089
|
+
for (const key of keys) {
|
|
2090
|
+
if (!["updateOne", "updateMany"].includes(key)) {
|
|
2091
|
+
return fn.error(`Invalid key ${key} for bulk update`, 400);
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2088
2094
|
}
|
|
2089
2095
|
|
|
2090
2096
|
for (const operation of updateOperations) {
|
|
2091
2097
|
let operationInstance = operation.updateMany || operation.updateOne;
|
|
2092
2098
|
|
|
2093
2099
|
if (operationInstance?.update) {
|
|
2100
|
+
operationInstance.filter = formatData(operationInstance.filter);
|
|
2094
2101
|
if (operationInstance?.update?.$set) {
|
|
2095
2102
|
operationInstance.update.$set = deepSetId(
|
|
2096
2103
|
col,
|