node_modules updated, buefy add to lib folder

This commit is contained in:
2019-06-04 14:29:48 +02:00
parent 0a3f6ff240
commit 5d28bc36e1
3957 changed files with 306575 additions and 21738 deletions
+28
View File
@@ -0,0 +1,28 @@
'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;
}
+38
View File
@@ -0,0 +1,38 @@
'use strict';
const each = require('async/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();
if (!subdocs.length) {
next();
return;
}
each(subdocs, function(subdoc, cb) {
subdoc.$__remove(function(err) {
cb(err);
});
}, function(error) {
if (error) {
return _this.schema.s.hooks.execPost('remove:error', _this, [_this], { error: error }, function(error) {
next(error);
});
}
next();
});
}, null, unshift);
};
+66
View File
@@ -0,0 +1,66 @@
'use strict';
const each = require('async/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);
};
+1 -1
View File
@@ -57,7 +57,7 @@ module.exports.storeShard = storeShard;
function storeShard() {
// backwards compat
const key = this.schema.options.shardKey || this.schema.options.shardkey;
if (!(key && utils.getFunctionName(key.constructor) === 'Object')) {
if (!utils.isPOJO(key)) {
return;
}
+44
View File
@@ -0,0 +1,44 @@
'use strict';
/*!
* ignore
*/
module.exports = function(schema) {
const unshift = true;
schema.pre('save', false, function(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) {
next(error);
});
});
} else {
next();
}
}, null, unshift);
};