Skip to content

Commit

Permalink
docs: add links to clarify truthy/falsy
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Nov 4, 2019
1 parent 2694cbd commit b3c95de
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
15 changes: 10 additions & 5 deletions lib/options/SchemaTypeOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'ref', opts);
Object.defineProperty(SchemaTypeOptions.prototype, 'select', opts);

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

/**
* If truthy, Mongoose will build a unique index on this path when the
* If [truthy](https://masteringjs.io/tutorials/fundamentals/truthy), Mongoose
* will build a unique index on this path when the
* model is compiled. [The `unique` option is **not** a validator](/docs/validation.html#the-unique-option-is-not-a-validator).
*
* @api public
Expand All @@ -133,7 +135,8 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'index', opts);
Object.defineProperty(SchemaTypeOptions.prototype, 'unique', opts);

/**
* If truthy, Mongoose will disallow changes to this path once the document
* If [truthy](https://masteringjs.io/tutorials/fundamentals/truthy), Mongoose will
* disallow changes to this path once the document
* is saved to the database for the first time. Read more about [immutability in Mongoose here](http://thecodebarbarian.com/whats-new-in-mongoose-5-6-immutable-properties.html).
*
* @api public
Expand All @@ -146,7 +149,8 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'unique', opts);
Object.defineProperty(SchemaTypeOptions.prototype, 'immutable', opts);

/**
* If truthy, Mongoose will build a sparse index on this path.
* If [truthy](https://masteringjs.io/tutorials/fundamentals/truthy), Mongoose will
* build a sparse index on this path.
*
* @api public
* @property sparse
Expand All @@ -158,7 +162,8 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'immutable', opts);
Object.defineProperty(SchemaTypeOptions.prototype, 'sparse', opts);

/**
* If truthy, Mongoose will build a text index on this path.
* If [truthy](https://masteringjs.io/tutorials/fundamentals/truthy), Mongoose
* will build a text index on this path.
*
* @api public
* @property text
Expand Down
4 changes: 2 additions & 2 deletions lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -1631,8 +1631,8 @@ Schema.prototype.indexes = function() {
* @param {String|Model} [options.ref] model name or model instance. Marks this as a [populate virtual](populate.html#populate-virtuals).
* @param {String|Function} [options.localField] Required for populate virtuals. See [populate virtual docs](populate.html#populate-virtuals) for more information.
* @param {String|Function} [options.foreignField] Required for populate virtuals. See [populate virtual docs](populate.html#populate-virtuals) for more information.
* @param {Boolean|Function} [options.justOne=false] Only works with populate virtuals. If truthy, will be a single doc or `null`. Otherwise, the populate virtual will be an array.
* @param {Boolean} [options.count=false] Only works with populate virtuals. If truthy, this populate virtual will contain the number of documents rather than the documents themselves when you `populate()`.
* @param {Boolean|Function} [options.justOne=false] Only works with populate virtuals. If [truthy](https://masteringjs.io/tutorials/fundamentals/truthy), will be a single doc or `null`. Otherwise, the populate virtual will be an array.
* @param {Boolean} [options.count=false] Only works with populate virtuals. If [truthy](https://masteringjs.io/tutorials/fundamentals/truthy), this populate virtual will contain the number of documents rather than the documents themselves when you `populate()`.
* @return {VirtualType}
*/

Expand Down
2 changes: 1 addition & 1 deletion lib/schematype.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ SchemaType.prototype.get = function(fn) {
* Product.on('error', handleError);
*
* @param {RegExp|Function|Object} obj validator function, or hash describing options
* @param {Function} [obj.validator] validator function. If the validator function returns `undefined` or a truthy value, validation succeeds. If it returns falsy (except `undefined`) or throws an error, validation fails.
* @param {Function} [obj.validator] validator function. If the validator function returns `undefined` or a truthy value, validation succeeds. If it returns [falsy](https://masteringjs.io/tutorials/fundamentals/falsy) (except `undefined`) or throws an error, validation fails.
* @param {String|Function} [obj.message] optional error message. If function, should return the error message as a string
* @param {Boolean} [obj.propsParameter=false] If true, Mongoose will pass the validator properties object (with the `validator` function, `message`, etc.) as the 2nd arg to the validator function. This is disabled by default because many validators [rely on positional args](https://github.com/chriso/validator.js#validators), so turning this on may cause unpredictable behavior in external validators.
* @param {String|Function} [errorMsg] optional error message. If function, should return the error message as a string
Expand Down

0 comments on commit b3c95de

Please sign in to comment.