@bedrockio/model 0.20.0 → 0.20.2
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/CHANGELOG.md
CHANGED
package/dist/cjs/schema.js
CHANGED
|
@@ -84,7 +84,13 @@ function normalizeAttributes(arg, path = []) {
|
|
|
84
84
|
} else if (typeof arg === 'object') {
|
|
85
85
|
const attributes = {};
|
|
86
86
|
for (let [key, val] of Object.entries(arg)) {
|
|
87
|
-
|
|
87
|
+
if (key === '_id' && val === false) {
|
|
88
|
+
// This is a special case in Mongoose that allows disabling
|
|
89
|
+
// the _id field for array objects so perserve it here.
|
|
90
|
+
attributes[key] = val;
|
|
91
|
+
} else {
|
|
92
|
+
attributes[key] = normalizeAttributes(val, [...path, key]);
|
|
93
|
+
}
|
|
88
94
|
}
|
|
89
95
|
return attributes;
|
|
90
96
|
}
|
package/dist/cjs/validation.js
CHANGED
|
@@ -194,6 +194,11 @@ function getObjectSchema(arg, options) {
|
|
|
194
194
|
} = options;
|
|
195
195
|
const map = {};
|
|
196
196
|
for (let [key, field] of Object.entries(arg)) {
|
|
197
|
+
if (key === '_id' && field === false) {
|
|
198
|
+
// This is a special case in Mongoose that allows disabling
|
|
199
|
+
// the _id field for array objects so skip it here.
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
197
202
|
if (!isExcludedField(field, options)) {
|
|
198
203
|
map[key] = getNestedSchema(field, options);
|
|
199
204
|
}
|
package/package.json
CHANGED
package/src/schema.js
CHANGED
|
@@ -89,7 +89,13 @@ export function normalizeAttributes(arg, path = []) {
|
|
|
89
89
|
} else if (typeof arg === 'object') {
|
|
90
90
|
const attributes = {};
|
|
91
91
|
for (let [key, val] of Object.entries(arg)) {
|
|
92
|
-
|
|
92
|
+
if (key === '_id' && val === false) {
|
|
93
|
+
// This is a special case in Mongoose that allows disabling
|
|
94
|
+
// the _id field for array objects so perserve it here.
|
|
95
|
+
attributes[key] = val;
|
|
96
|
+
} else {
|
|
97
|
+
attributes[key] = normalizeAttributes(val, [...path, key]);
|
|
98
|
+
}
|
|
93
99
|
}
|
|
94
100
|
return attributes;
|
|
95
101
|
}
|
package/src/validation.js
CHANGED
|
@@ -209,6 +209,11 @@ function getObjectSchema(arg, options) {
|
|
|
209
209
|
const map = {};
|
|
210
210
|
|
|
211
211
|
for (let [key, field] of Object.entries(arg)) {
|
|
212
|
+
if (key === '_id' && field === false) {
|
|
213
|
+
// This is a special case in Mongoose that allows disabling
|
|
214
|
+
// the _id field for array objects so skip it here.
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
212
217
|
if (!isExcludedField(field, options)) {
|
|
213
218
|
map[key] = getNestedSchema(field, options);
|
|
214
219
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema.js"],"names":[],"mappings":"AAyBA;;;;;;;GAOG;AACH,yCAJW,MAAM,YACN,QAAQ,CAAC,aAAa,GACpB,QAAQ,CAAC,MAAM,CAgD3B;AAED,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema.js"],"names":[],"mappings":"AAyBA;;;;;;;GAOG;AACH,yCAJW,MAAM,YACN,QAAQ,CAAC,aAAa,GACpB,QAAQ,CAAC,MAAM,CAgD3B;AAED,iEAoBC;qBApGoB,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/validation.js"],"names":[],"mappings":"AA6DA,kDAEC;AAED,oEA4FC;AAsBD,wEAiBC;
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/validation.js"],"names":[],"mappings":"AA6DA,kDAEC;AAED,oEA4FC;AAsBD,wEAiBC;AAwUD;;;EAEC;AAED;;;EAOC"}
|