diff options
author | 2020-11-18 23:26:45 +0100 | |
---|---|---|
committer | 2020-11-18 23:26:45 +0100 | |
commit | 81ddf9b700bc48a1f8e472209f080f9c1d9a9b09 (patch) | |
tree | 8b959d50c5a614cbf9fcb346ed556140374d4b6d /node_modules/mongoose/lib/plugins | |
parent | 1870f3fdf43707a15fda0f609a021f516f45eb63 (diff) | |
download | website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.tar.gz website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.tar.bz2 website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.zip |
rm node_modules
Diffstat (limited to 'node_modules/mongoose/lib/plugins')
-rw-r--r-- | node_modules/mongoose/lib/plugins/idGetter.js | 28 | ||||
-rw-r--r-- | node_modules/mongoose/lib/plugins/removeSubdocs.js | 31 | ||||
-rw-r--r-- | node_modules/mongoose/lib/plugins/saveSubdocs.js | 66 | ||||
-rw-r--r-- | node_modules/mongoose/lib/plugins/sharding.js | 83 | ||||
-rw-r--r-- | node_modules/mongoose/lib/plugins/trackTransaction.js | 91 | ||||
-rw-r--r-- | node_modules/mongoose/lib/plugins/validateBeforeSave.js | 45 |
6 files changed, 0 insertions, 344 deletions
diff --git a/node_modules/mongoose/lib/plugins/idGetter.js b/node_modules/mongoose/lib/plugins/idGetter.js deleted file mode 100644 index f4e6356..0000000 --- a/node_modules/mongoose/lib/plugins/idGetter.js +++ /dev/null @@ -1,28 +0,0 @@ -'use strict'; - -/*! - * ignore - */ - -module.exports = function(schema) { - // ensure the documents receive an id getter unless disabled - const autoIdGetter = !schema.paths['id'] && - (!schema.options.noVirtualId && schema.options.id); - if (!autoIdGetter) { - return; - } - - schema.virtual('id').get(idGetter); -}; - -/*! - * Returns this documents _id cast to a string. - */ - -function idGetter() { - if (this._id != null) { - return String(this._id); - } - - return null; -} diff --git a/node_modules/mongoose/lib/plugins/removeSubdocs.js b/node_modules/mongoose/lib/plugins/removeSubdocs.js deleted file mode 100644 index 44b2ea6..0000000 --- a/node_modules/mongoose/lib/plugins/removeSubdocs.js +++ /dev/null @@ -1,31 +0,0 @@ -'use strict'; - -const each = require('../helpers/each'); - -/*! - * ignore - */ - -module.exports = function(schema) { - const unshift = true; - schema.s.hooks.pre('remove', false, function(next) { - if (this.ownerDocument) { - next(); - return; - } - - const _this = this; - const subdocs = this.$__getAllSubdocs(); - - each(subdocs, function(subdoc, cb) { - subdoc.$__remove(cb); - }, function(error) { - if (error) { - return _this.schema.s.hooks.execPost('remove:error', _this, [_this], { error: error }, function(error) { - next(error); - }); - } - next(); - }); - }, null, unshift); -}; diff --git a/node_modules/mongoose/lib/plugins/saveSubdocs.js b/node_modules/mongoose/lib/plugins/saveSubdocs.js deleted file mode 100644 index c0a3144..0000000 --- a/node_modules/mongoose/lib/plugins/saveSubdocs.js +++ /dev/null @@ -1,66 +0,0 @@ -'use strict'; - -const each = require('../helpers/each'); - -/*! - * ignore - */ - -module.exports = function(schema) { - const unshift = true; - schema.s.hooks.pre('save', false, function(next) { - if (this.ownerDocument) { - next(); - return; - } - - const _this = this; - const subdocs = this.$__getAllSubdocs(); - - if (!subdocs.length) { - next(); - return; - } - - each(subdocs, function(subdoc, cb) { - subdoc.schema.s.hooks.execPre('save', subdoc, function(err) { - cb(err); - }); - }, function(error) { - if (error) { - return _this.schema.s.hooks.execPost('save:error', _this, [_this], { error: error }, function(error) { - next(error); - }); - } - next(); - }); - }, null, unshift); - - schema.s.hooks.post('save', function(doc, next) { - if (this.ownerDocument) { - next(); - return; - } - - const _this = this; - const subdocs = this.$__getAllSubdocs(); - - if (!subdocs.length) { - next(); - return; - } - - each(subdocs, function(subdoc, cb) { - subdoc.schema.s.hooks.execPost('save', subdoc, [subdoc], function(err) { - cb(err); - }); - }, function(error) { - if (error) { - return _this.schema.s.hooks.execPost('save:error', _this, [_this], { error: error }, function(error) { - next(error); - }); - } - next(); - }); - }, null, unshift); -}; diff --git a/node_modules/mongoose/lib/plugins/sharding.js b/node_modules/mongoose/lib/plugins/sharding.js deleted file mode 100644 index 560053e..0000000 --- a/node_modules/mongoose/lib/plugins/sharding.js +++ /dev/null @@ -1,83 +0,0 @@ -'use strict'; - -const objectIdSymbol = require('../helpers/symbols').objectIdSymbol; -const utils = require('../utils'); - -/*! - * ignore - */ - -module.exports = function shardingPlugin(schema) { - schema.post('init', function() { - storeShard.call(this); - return this; - }); - schema.pre('save', function(next) { - applyWhere.call(this); - next(); - }); - schema.pre('remove', function(next) { - applyWhere.call(this); - next(); - }); - schema.post('save', function() { - storeShard.call(this); - }); -}; - -/*! - * ignore - */ - -function applyWhere() { - let paths; - let len; - - if (this.$__.shardval) { - paths = Object.keys(this.$__.shardval); - len = paths.length; - - this.$where = this.$where || {}; - for (let i = 0; i < len; ++i) { - this.$where[paths[i]] = this.$__.shardval[paths[i]]; - } - } -} - -/*! - * ignore - */ - -module.exports.storeShard = storeShard; - -/*! - * ignore - */ - -function storeShard() { - // backwards compat - const key = this.schema.options.shardKey || this.schema.options.shardkey; - if (!utils.isPOJO(key)) { - return; - } - - const orig = this.$__.shardval = {}; - const paths = Object.keys(key); - const len = paths.length; - let val; - - for (let i = 0; i < len; ++i) { - val = this.$__getValue(paths[i]); - if (val == null) { - orig[paths[i]] = val; - } else if (utils.isMongooseObject(val)) { - orig[paths[i]] = val.toObject({ depopulate: true, _isNested: true }); - } else if (val instanceof Date || val[objectIdSymbol]) { - orig[paths[i]] = val; - } else if (typeof val.valueOf === 'function') { - orig[paths[i]] = val.valueOf(); - } else { - orig[paths[i]] = val; - } - } -} diff --git a/node_modules/mongoose/lib/plugins/trackTransaction.js b/node_modules/mongoose/lib/plugins/trackTransaction.js deleted file mode 100644 index 410a596..0000000 --- a/node_modules/mongoose/lib/plugins/trackTransaction.js +++ /dev/null @@ -1,91 +0,0 @@ -'use strict'; - -const arrayAtomicsSymbol = require('../helpers/symbols').arrayAtomicsSymbol; -const sessionNewDocuments = require('../helpers/symbols').sessionNewDocuments; - -module.exports = function trackTransaction(schema) { - schema.pre('save', function() { - const session = this.$session(); - if (session == null) { - return; - } - if (session.transaction == null || session[sessionNewDocuments] == null) { - return; - } - - if (!session[sessionNewDocuments].has(this)) { - const initialState = {}; - if (this.isNew) { - initialState.isNew = true; - } - if (this.schema.options.versionKey) { - initialState.versionKey = this.get(this.schema.options.versionKey); - } - - initialState.modifiedPaths = new Set(Object.keys(this.$__.activePaths.states.modify)); - initialState.atomics = _getAtomics(this); - - session[sessionNewDocuments].set(this, initialState); - } else { - const state = session[sessionNewDocuments].get(this); - - for (const path of Object.keys(this.$__.activePaths.states.modify)) { - state.modifiedPaths.add(path); - } - state.atomics = _getAtomics(this, state.atomics); - } - }); -}; - -function _getAtomics(doc, previous) { - const pathToAtomics = new Map(); - previous = previous || new Map(); - - const pathsToCheck = Object.keys(doc.$__.activePaths.init).concat(Object.keys(doc.$__.activePaths.modify)); - - for (const path of pathsToCheck) { - const val = doc.$__getValue(path); - if (val != null && - val instanceof Array && - val.isMongooseDocumentArray && - val.length && - val[arrayAtomicsSymbol] != null && - Object.keys(val[arrayAtomicsSymbol]).length > 0) { - const existing = previous.get(path) || {}; - pathToAtomics.set(path, mergeAtomics(existing, val[arrayAtomicsSymbol])); - } - } - - const dirty = doc.$__dirty(); - for (const dirt of dirty) { - const path = dirt.path; - - const val = dirt.value; - if (val != null && val[arrayAtomicsSymbol] != null && Object.keys(val[arrayAtomicsSymbol]).length > 0) { - const existing = previous.get(path) || {}; - pathToAtomics.set(path, mergeAtomics(existing, val[arrayAtomicsSymbol])); - } - } - - return pathToAtomics; -} - -function mergeAtomics(destination, source) { - destination = destination || {}; - - if (source.$pullAll != null) { - destination.$pullAll = (destination.$pullAll || []).concat(source.$pullAll); - } - if (source.$push != null) { - destination.$push = destination.$push || {}; - destination.$push.$each = (destination.$push.$each || []).concat(source.$push.$each); - } - if (source.$addToSet != null) { - destination.$addToSet = (destination.$addToSet || []).concat(source.$addToSet); - } - if (source.$set != null) { - destination.$set = Object.assign(destination.$set || {}, source.$set); - } - - return destination; -}
\ No newline at end of file diff --git a/node_modules/mongoose/lib/plugins/validateBeforeSave.js b/node_modules/mongoose/lib/plugins/validateBeforeSave.js deleted file mode 100644 index 4635de1..0000000 --- a/node_modules/mongoose/lib/plugins/validateBeforeSave.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; - -/*! - * ignore - */ - -module.exports = function(schema) { - const unshift = true; - schema.pre('save', false, function validateBeforeSave(next, options) { - const _this = this; - // Nested docs have their own presave - if (this.ownerDocument) { - return next(); - } - - const hasValidateBeforeSaveOption = options && - (typeof options === 'object') && - ('validateBeforeSave' in options); - - let shouldValidate; - if (hasValidateBeforeSaveOption) { - shouldValidate = !!options.validateBeforeSave; - } else { - shouldValidate = this.schema.options.validateBeforeSave; - } - - // Validate - if (shouldValidate) { - const hasValidateModifiedOnlyOption = options && - (typeof options === 'object') && - ('validateModifiedOnly' in options); - const validateOptions = hasValidateModifiedOnlyOption ? - { validateModifiedOnly: options.validateModifiedOnly } : - null; - this.validate(validateOptions, function(error) { - return _this.schema.s.hooks.execPost('save:error', _this, [_this], { error: error }, function(error) { - _this.$op = 'save'; - next(error); - }); - }); - } else { - next(); - } - }, null, unshift); -}; |