-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
_id: false
in schema paths as a shortcut for se…
…tting the `_id` option to `false` Fix #7480
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -388,13 +388,18 @@ Schema.prototype.add = function add(obj, prefix) { | |
return; | ||
} | ||
|
||
if (obj._id === false) { | ||
delete obj._id; | ||
this.options._id = false; | ||
} | ||
|
||
prefix = prefix || ''; | ||
const keys = Object.keys(obj); | ||
|
||
for (let i = 0; i < keys.length; ++i) { | ||
const key = keys[i]; | ||
|
||
if (obj[key] == null) { | ||
if (obj[key] == null || obj[key] === false) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
travist
|
||
throw new TypeError('Invalid value for schema path `' + prefix + key + '`'); | ||
} | ||
|
||
|
@vkarpov15 This introduces a break where, for example, we set a schema path with
select: false
https://mongoosejs.com/docs/api.html#schematype_SchemaType-select