This commit is contained in:
Jonasz Bigda
2023-03-25 21:51:42 +01:00
parent 0db1d5117e
commit b332e9ceb0
1044 changed files with 37502 additions and 63938 deletions

View File

@@ -5,6 +5,7 @@ const clone = require('../helpers/clone');
class PopulateOptions {
constructor(obj) {
this._docs = {};
this._childDocs = [];
if (obj == null) {
return;

View File

@@ -32,6 +32,26 @@ const opts = require('./propertyOptions');
Object.defineProperty(SchemaArrayOptions.prototype, 'enum', opts);
/**
* If set, specifies the type of this array's values. Equivalent to setting
* `type` to an array whose first element is `of`.
*
* ####Example:
*
* // `arr` is an array of numbers.
* new Schema({ arr: [Number] });
* // Equivalent way to define `arr` as an array of numbers
* new Schema({ arr: { type: Array, of: Number } });
*
* @api public
* @property of
* @memberOf SchemaArrayOptions
* @type Function|String
* @instance
*/
Object.defineProperty(SchemaArrayOptions.prototype, 'of', opts);
/*!
* ignore
*/

View File

@@ -67,6 +67,31 @@ Object.defineProperty(SchemaNumberOptions.prototype, 'max', opts);
Object.defineProperty(SchemaNumberOptions.prototype, 'enum', opts);
/**
* Sets default [populate options](/docs/populate.html#query-conditions).
*
* ####Example:
* const schema = new Schema({
* child: {
* type: Number,
* ref: 'Child',
* populate: { select: 'name' }
* }
* });
* const Parent = mongoose.model('Parent', schema);
*
* // Automatically adds `.select('name')`
* Parent.findOne().populate('child');
*
* @api public
* @property populate
* @memberOf SchemaNumberOptions
* @type Object
* @instance
*/
Object.defineProperty(SchemaNumberOptions.prototype, 'populate', opts);
/*!
* ignore
*/

View File

@@ -31,6 +31,31 @@ const opts = require('./propertyOptions');
Object.defineProperty(SchemaObjectIdOptions.prototype, 'auto', opts);
/**
* Sets default [populate options](/docs/populate.html#query-conditions).
*
* ####Example:
* const schema = new Schema({
* child: {
* type: 'ObjectId',
* ref: 'Child',
* populate: { select: 'name' }
* }
* });
* const Parent = mongoose.model('Parent', schema);
*
* // Automatically adds `.select('name')`
* Parent.findOne().populate('child');
*
* @api public
* @property populate
* @memberOf SchemaObjectIdOptions
* @type Object
* @instance
*/
Object.defineProperty(SchemaObjectIdOptions.prototype, 'populate', opts);
/*!
* ignore
*/

View File

@@ -87,30 +87,52 @@ Object.defineProperty(SchemaStringOptions.prototype, 'uppercase', opts);
* If set, Mongoose will add a custom validator that ensures the given
* string's `length` is at least the given number.
*
* Mongoose supports two different spellings for this option: `minLength` and `minlength`.
* `minLength` is the recommended way to specify this option, but Mongoose also supports
* `minlength` (lowercase "l").
*
* @api public
* @property minlength
* @property minLength
* @memberOf SchemaStringOptions
* @type Number
* @instance
*/
Object.defineProperty(SchemaStringOptions.prototype, 'minLength', opts);
Object.defineProperty(SchemaStringOptions.prototype, 'minlength', opts);
/**
* If set, Mongoose will add a custom validator that ensures the given
* string's `length` is at most the given number.
*
* Mongoose supports two different spellings for this option: `maxLength` and `maxlength`.
* `maxLength` is the recommended way to specify this option, but Mongoose also supports
* `maxlength` (lowercase "l").
*
* @api public
* @property maxlength
* @property maxLength
* @memberOf SchemaStringOptions
* @type Number
* @instance
*/
Object.defineProperty(SchemaStringOptions.prototype, 'maxLength', opts);
Object.defineProperty(SchemaStringOptions.prototype, 'maxlength', opts);
/**
* Sets default [populate options](/docs/populate.html#query-conditions).
*
* @api public
* @property populate
* @memberOf SchemaStringOptions
* @type Object
* @instance
*/
Object.defineProperty(SchemaStringOptions.prototype, 'populate', opts);
/*!
* ignore
*/
module.exports = SchemaStringOptions;
module.exports = SchemaStringOptions;

View File

@@ -134,8 +134,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'select', opts);
/**
* If [truthy](https://masteringjs.io/tutorials/fundamentals/truthy), Mongoose will
* build an index on this path when the model is
* compiled.
* build an index on this path when the model is compiled.
*
* @api public
* @property index