mirror of
https://github.com/JonasunderscoreJones/jonas_jones-api.git
synced 2025-10-25 01:59:18 +02:00
some progress
This commit is contained in:
parent
aea93a5527
commit
e3c15bd288
1388 changed files with 306946 additions and 68323 deletions
28
node_modules/mongoose/lib/helpers/query/handleImmutable.js
generated
vendored
Normal file
28
node_modules/mongoose/lib/helpers/query/handleImmutable.js
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
'use strict';
|
||||
|
||||
const StrictModeError = require('../../error/strict');
|
||||
|
||||
module.exports = function handleImmutable(schematype, strict, obj, key, fullPath, ctx) {
|
||||
if (schematype == null || !schematype.options || !schematype.options.immutable) {
|
||||
return false;
|
||||
}
|
||||
let immutable = schematype.options.immutable;
|
||||
|
||||
if (typeof immutable === 'function') {
|
||||
immutable = immutable.call(ctx, ctx);
|
||||
}
|
||||
if (!immutable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strict === false) {
|
||||
return false;
|
||||
}
|
||||
if (strict === 'throw') {
|
||||
throw new StrictModeError(null,
|
||||
`Field ${fullPath} is immutable and strict = 'throw'`);
|
||||
}
|
||||
|
||||
delete obj[key];
|
||||
return true;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue