@bedrockio/model 0.20.0 → 0.20.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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.20.1
2
+
3
+ - Fixed `_id: false` on array fields.
4
+
1
5
  ## 0.20.0
2
6
 
3
7
  - Added types and documentation to all augmented methods.
@@ -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
- attributes[key] = normalizeAttributes(val, [...path, key]);
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/model",
3
- "version": "0.20.0",
3
+ "version": "0.20.1",
4
4
  "description": "Bedrock utilities for model creation.",
5
5
  "type": "module",
6
6
  "scripts": {
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
- attributes[key] = normalizeAttributes(val, [...path, key]);
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
  }
@@ -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,iEAcC;qBA9FoB,UAAU"}
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"}