diff --git a/.eslintrc.js b/.eslintrc.js index 0b98da74134..5377c64c6c2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -11,7 +11,7 @@ module.exports = { 'test/files/*', 'benchmarks', '*.min.js', - 'docs/js/native.js' + '**/docs/js/native.js' ], overrides: [ { @@ -77,7 +77,7 @@ module.exports = { }, { files: [ - 'docs/js/**/*.js' + '**/docs/js/**/*.js' ], env: { node: false, diff --git a/docs/source/api.js b/docs/source/api.js index 45510b423a5..5c13d003d44 100644 --- a/docs/source/api.js +++ b/docs/source/api.js @@ -41,7 +41,8 @@ const files = [ 'lib/types/ArraySubdocument.js', 'lib/types/buffer.js', 'lib/types/decimal128.js', - 'lib/types/map.js' + 'lib/types/map.js', + 'lib/types/array/methods/index.js' ]; /** @type {Map.} */ @@ -179,6 +180,9 @@ function processName(input) { name += basename; } } + if (fullName === 'types/array/methods/index') { + name = 'Array'; + } if (basename === 'SubdocumentPath') { name = 'SubdocumentPath'; } diff --git a/docs/tutorials/findoneandupdate.md b/docs/tutorials/findoneandupdate.md index d1c0901ca9b..28a89a92a57 100644 --- a/docs/tutorials/findoneandupdate.md +++ b/docs/tutorials/findoneandupdate.md @@ -1,6 +1,6 @@ # How to Use `findOneAndUpdate()` in Mongoose -The [`findOneAndUpdate()` function in Mongoose](../api/query.html#query_Query-findOneAndUpdate) has a wide variety of use cases. [You should use `save()` to update documents where possible](https://masteringjs.io/tutorials/mongoose/update), for better [validation](../validation) and [middleware](../middleware) support. +The [`findOneAndUpdate()` function in Mongoose](../api/query.html#query_Query-findOneAndUpdate) has a wide variety of use cases. [You should use `save()` to update documents where possible](https://masteringjs.io/tutorials/mongoose/update), for better [validation](../validation.html) and [middleware](../middleware.html) support. However, there are some cases where you need to use [`findOneAndUpdate()`](https://masteringjs.io/tutorials/mongoose/findoneandupdate). In this tutorial, you'll see how to use `findOneAndUpdate()`, and learn when you need to use it. * [Getting Started](#getting-started) diff --git a/lib/aggregate.js b/lib/aggregate.js index cbeef62b496..e2dace83389 100644 --- a/lib/aggregate.js +++ b/lib/aggregate.js @@ -20,7 +20,7 @@ const validRedactStringValues = new Set(['$$DESCEND', '$$PRUNE', '$$KEEP']); /** * Aggregate constructor used for building aggregation pipelines. Do not - * instantiate this class directly, use [Model.aggregate()](/docs/api/model.html#model_Model-aggregate) instead. + * instantiate this class directly, use [Model.aggregate()](https://mongoosejs.com/docs/api/model.html#Model.aggregate()) instead. * * #### Example: * @@ -64,20 +64,20 @@ function Aggregate(pipeline, model) { * Contains options passed down to the [aggregate command](https://www.mongodb.com/docs/manual/reference/command/aggregate/). * Supported options are: * - * - [`allowDiskUse`](#aggregate_Aggregate-allowDiskUse) + * - [`allowDiskUse`](https://mongoosejs.com/docs/api/aggregate.html#Aggregate.prototype.allowDiskUse()) * - `bypassDocumentValidation` - * - [`collation`](#aggregate_Aggregate-collation) + * - [`collation`](https://mongoosejs.com/docs/api/aggregate.html#Aggregate.prototype.collation()) * - `comment` - * - [`cursor`](#aggregate_Aggregate-cursor) - * - [`explain`](#aggregate_Aggregate-explain) + * - [`cursor`](https://mongoosejs.com/docs/api/aggregate.html#Aggregate.prototype.cursor()) + * - [`explain`](https://mongoosejs.com/docs/api/aggregate.html#Aggregate.prototype.explain()) * - `fieldsAsRaw` - * - [`hint`](#aggregate_Aggregate-hint) + * - [`hint`](https://mongoosejs.com/docs/api/aggregate.html#Aggregate.prototype.hint()) * - `let` * - `maxTimeMS` * - `raw` - * - [`readConcern`](#aggregate_Aggregate-readConcern) + * - [`readConcern`](https://mongoosejs.com/docs/api/aggregate.html#Aggregate.prototype.readConcern()) * - `readPreference` - * - [`session`](#aggregate_Aggregate-session) + * - [`session`](https://mongoosejs.com/docs/api/aggregate.html#Aggregate.prototype.session()) * - `writeConcern` * * @property options @@ -187,7 +187,7 @@ Aggregate.prototype.addFields = function(arg) { /** * Appends a new $project operator to this aggregate pipeline. * - * Mongoose query [selection syntax](#query_Query-select) is also supported. + * Mongoose query [selection syntax](https://mongoosejs.com/docs/api/query.html#Query.prototype.select()) is also supported. * * #### Example: * @@ -847,7 +847,7 @@ Aggregate.prototype.hint = function(value) { }; /** - * Sets the session for this aggregation. Useful for [transactions](/docs/transactions.html). + * Sets the session for this aggregation. Useful for [transactions](https://mongoosejs.com/docs/transactions.html). * * #### Example: * @@ -879,8 +879,8 @@ Aggregate.prototype.session = function(session) { * @param {Object} options keys to merge into current options * @param {Number} [options.maxTimeMS] number limits the time this aggregation will run, see [MongoDB docs on `maxTimeMS`](https://www.mongodb.com/docs/manual/reference/operator/meta/maxTimeMS/) * @param {Boolean} [options.allowDiskUse] boolean if true, the MongoDB server will use the hard drive to store data during this aggregation - * @param {Object} [options.collation] object see [`Aggregate.prototype.collation()`](#aggregate_Aggregate-collation) - * @param {ClientSession} [options.session] ClientSession see [`Aggregate.prototype.session()`](#aggregate_Aggregate-session) + * @param {Object} [options.collation] object see [`Aggregate.prototype.collation()`](https://mongoosejs.com/docs/api/aggregate.html#Aggregate.prototype.collation()) + * @param {ClientSession} [options.session] ClientSession see [`Aggregate.prototype.session()`](https://mongoosejs.com/docs/api/aggregate.html#Aggregate.prototype.session()) * @see mongodb https://www.mongodb.com/docs/manual/reference/command/aggregate/ * @return {Aggregate} this * @api public @@ -1096,7 +1096,7 @@ Aggregate.prototype.then = function(resolve, reject) { /** * Executes the query returning a `Promise` which will be * resolved with either the doc(s) or rejected with the error. - * Like [`.then()`](#query_Query-then), but only takes a rejection handler. + * Like [`.then()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.then), but only takes a rejection handler. * Compatible with `await`. * * @param {Function} [reject] diff --git a/lib/browser.js b/lib/browser.js index c6f3b80cdfd..aef666b85a0 100644 --- a/lib/browser.js +++ b/lib/browser.js @@ -9,7 +9,7 @@ const DocumentProvider = require('./document_provider.js'); DocumentProvider.setBrowser(true); /** - * The [MongooseError](#error_MongooseError) constructor. + * The [MongooseError](https://mongoosejs.com/docs/api/error.html#Error()) constructor. * * @method Error * @api public @@ -18,7 +18,7 @@ DocumentProvider.setBrowser(true); exports.Error = require('./error/index'); /** - * The Mongoose [Schema](#schema_Schema) constructor + * The Mongoose [Schema](https://mongoosejs.com/docs/api/schema.html#Schema()) constructor * * #### Example: * @@ -42,14 +42,14 @@ exports.Schema = require('./schema'); * * #### Types: * - * - [Array](/docs/schematypes.html#arrays) - * - [Buffer](/docs/schematypes.html#buffers) - * - [Embedded](/docs/schematypes.html#schemas) - * - [DocumentArray](/docs/api/documentarraypath.html) - * - [Decimal128](/docs/api/mongoose.html#mongoose_Mongoose-Decimal128) - * - [ObjectId](/docs/schematypes.html#objectids) - * - [Map](/docs/schematypes.html#maps) - * - [Subdocument](/docs/schematypes.html#schemas) + * - [Array](https://mongoosejs.com/docs/schematypes.html#arrays) + * - [Buffer](https://mongoosejs.com/docs/schematypes.html#buffers) + * - [Embedded](https://mongoosejs.com/docs/schematypes.html#schemas) + * - [DocumentArray](https://mongoosejs.com/docs/api/documentarraypath.html) + * - [Decimal128](https://mongoosejs.com/docs/api/decimal128.html#Decimal128()) + * - [ObjectId](https://mongoosejs.com/docs/schematypes.html#objectids) + * - [Map](https://mongoosejs.com/docs/schematypes.html#maps) + * - [Subdocument](https://mongoosejs.com/docs/schematypes.html#schemas) * * Using this exposed access to the `ObjectId` type, we can construct ids on demand. * @@ -62,7 +62,7 @@ exports.Schema = require('./schema'); exports.Types = require('./types'); /** - * The Mongoose [VirtualType](#virtualtype_VirtualType) constructor + * The Mongoose [VirtualType](https://mongoosejs.com/docs/api/virtualtype.html#VirtualType()) constructor * * @method VirtualType * @api public @@ -77,7 +77,7 @@ exports.VirtualType = require('./virtualtype'); * _Alias of mongoose.Schema.Types for backwards compatibility._ * * @property SchemaTypes - * @see Schema.SchemaTypes #schema_Schema-Types + * @see Schema.SchemaTypes https://mongoosejs.com/docs/api/schema.html#Schema.Types * @api public */ diff --git a/lib/connection.js b/lib/connection.js index a2769614de5..017c47b2d4f 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -152,7 +152,7 @@ Connection.prototype.get = function(key) { * * Supported options include: * - * - `maxTimeMS`: Set [`maxTimeMS`](/docs/api/query.html#query_Query-maxTimeMS) for all queries on this connection. + * - `maxTimeMS`: Set [`maxTimeMS`](https://mongoosejs.com/docs/api/query.html#Query.prototype.maxTimeMS()) for all queries on this connection. * - 'debug': If `true`, prints the operations mongoose sends to MongoDB to the console. If a writable stream is passed, it will log to that stream, without colorization. If a callback function is passed, it will receive the collection name, the method name, then all arugments passed to the method. For example, if you wanted to replicate the default logging, you could output from the callback `Mongoose: ${collectionName}.${methodName}(${methodArgs.join(', ')})`. * * #### Example: @@ -207,7 +207,7 @@ Connection.prototype.name; /** * A [POJO](https://masteringjs.io/tutorials/fundamentals/pojo) containing * a map from model names to models. Contains all models that have been - * added to this connection using [`Connection#model()`](/docs/api/connection.html#connection_Connection-model). + * added to this connection using [`Connection#model()`](https://mongoosejs.com/docs/api/connection.html#Connection.prototype.model()). * * #### Example: * @@ -227,7 +227,7 @@ Connection.prototype.models; /** * A number identifier for this connection. Used for debugging when - * you have [multiple connections](/docs/connections.html#multiple_connections). + * you have [multiple connections](https://mongoosejs.com/docs/connections.html#multiple_connections). * * #### Example: * @@ -939,7 +939,7 @@ function _setClient(conn, client, options, dbName) { } /** - * Destory the connection (not just a alias of [`.close`](#connection_Connection-close)) + * Destory the connection (not just a alias of [`.close`](https://mongoosejs.com/docs/api/connection.html#Connection.prototype.close())) * * @param {Boolean} [force] * @returns {Promise} @@ -1132,7 +1132,7 @@ Connection.prototype.collection = function(name, options) { * @param {Function} fn plugin callback * @param {Object} [opts] optional options * @return {Connection} this - * @see plugins /docs/plugins.html + * @see plugins https://mongoosejs.com/docs/plugins.html * @api public */ @@ -1150,7 +1150,7 @@ Connection.prototype.plugin = function(fn, opts) { * const Ticket = db.model('Ticket', new Schema(..)); * const Venue = db.model('Venue'); * - * _When no `collection` argument is passed, Mongoose produces a collection name by passing the model `name` to the [utils.toCollectionName](#utils_exports-toCollectionName) method. This method pluralizes the name. If you don't like this behavior, either pass a collection name or set your schemas collection name option._ + * _When no `collection` argument is passed, Mongoose produces a collection name by passing the model `name` to the `utils.toCollectionName` method. This method pluralizes the name. If you don't like this behavior, either pass a collection name or set your schemas collection name option._ * * #### Example: * @@ -1170,7 +1170,7 @@ Connection.prototype.plugin = function(fn, opts) { * @param {String} [collection] name of mongodb collection (optional) if not given it will be induced from model name * @param {Object} [options] * @param {Boolean} [options.overwriteModels=false] If true, overwrite existing models with the same name to avoid `OverwriteModelError` - * @see Mongoose#model #index_Mongoose-model + * @see Mongoose#model https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.model() * @return {Model} The compiled model * @api public */ @@ -1324,7 +1324,7 @@ Connection.prototype.deleteModel = function(name) { /** * Watches the entire underlying database for changes. Similar to - * [`Model.watch()`](/docs/api/model.html#model_Model-watch). + * [`Model.watch()`](https://mongoosejs.com/docs/api/model.html#Model.watch()). * * This function does **not** trigger any middleware. In particular, it * does **not** trigger aggregate middleware. diff --git a/lib/cursor/AggregationCursor.js b/lib/cursor/AggregationCursor.js index c2e9cd41a15..9b3e4795722 100644 --- a/lib/cursor/AggregationCursor.js +++ b/lib/cursor/AggregationCursor.js @@ -22,7 +22,7 @@ const util = require('util'); * but **not** the model's post aggregate hooks. * * Unless you're an advanced user, do **not** instantiate this class directly. - * Use [`Aggregate#cursor()`](/docs/api/aggregate.html#aggregate_Aggregate-cursor) instead. + * Use [`Aggregate#cursor()`](https://mongoosejs.com/docs/api/aggregate.html#Aggregate.prototype.cursor()) instead. * * @param {Aggregate} agg * @inherits Readable https://nodejs.org/api/stream.html#class-streamreadable diff --git a/lib/cursor/QueryCursor.js b/lib/cursor/QueryCursor.js index 0cd1abfaf30..9c04e7a0ecb 100644 --- a/lib/cursor/QueryCursor.js +++ b/lib/cursor/QueryCursor.js @@ -21,7 +21,7 @@ const util = require('util'); * from MongoDB, and the model's post `find` hooks after loading each document. * * Unless you're an advanced user, do **not** instantiate this class directly. - * Use [`Query#cursor()`](/docs/api/query.html#query_Query-cursor) instead. + * Use [`Query#cursor()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.cursor()) instead. * * @param {Query} query * @param {Object} options query options passed to `.find()` diff --git a/lib/document.js b/lib/document.js index 616104107a3..aacd688b452 100644 --- a/lib/document.js +++ b/lib/document.js @@ -211,7 +211,7 @@ Document.prototype.$isMongooseDocumentPrototype = true; * await user.save(); // Sends an `insertOne` to MongoDB * * On the other hand, if you load an existing document from the database - * using `findOne()` or another [query operation](/docs/queries.html), + * using `findOne()` or another [query operation](https://mongoosejs.com/docs/queries.html), * `$isNew` will be false. * * #### Example: @@ -375,7 +375,7 @@ Object.defineProperty(Document.prototype, '$locals', { * @api public * @property isNew * @memberOf Document - * @see $isNew #document_Document-$isNew + * @see $isNew https://mongoosejs.com/docs/api/document.html#Document.prototype.$isNew * @instance */ @@ -408,12 +408,12 @@ Object.defineProperty(Document.prototype, '$where', { * * #### Note: * - * This getter exists on all documents by default. The getter can be disabled by setting the `id` [option](/docs/guide.html#id) of its `Schema` to false at construction time. + * This getter exists on all documents by default. The getter can be disabled by setting the `id` [option](https://mongoosejs.com/docs/guide.html#id) of its `Schema` to false at construction time. * * new Schema({ name: String }, { id: false }); * * @api public - * @see Schema options /docs/guide.html#options + * @see Schema options https://mongoosejs.com/docs/guide.html#options * @property id * @memberOf Document * @instance @@ -617,8 +617,8 @@ Document.prototype.toBSON = function() { * Called internally after a document is returned from mongodb. Normally, * you do **not** need to call this function on your own. * - * This function triggers `init` [middleware](/docs/middleware.html). - * Note that `init` hooks are [synchronous](/docs/middleware.html#synchronous). + * This function triggers `init` [middleware](https://mongoosejs.com/docs/middleware.html). + * Note that `init` hooks are [synchronous](https://mongoosejs.com/docs/middleware.html#synchronous). * * @param {Object} doc document returned by mongo * @param {Object} [opts] @@ -644,7 +644,7 @@ Document.prototype.init = function(doc, opts, fn) { }; /** - * Alias for [`.init`](#document_Document-init) + * Alias for [`.init`](https://mongoosejs.com/docs/api/document.html#Document.prototype.init()) * * @api public */ @@ -812,14 +812,14 @@ function init(self, obj, doc, opts, prefix) { * * #### Valid options: * - * - same as in [Model.updateOne](#model_Model-updateOne) + * - same as in [Model.updateOne](https://mongoosejs.com/docs/api/model.html#Model.updateOne) * - * @see Model.updateOne #model_Model-updateOne + * @see Model.updateOne https://mongoosejs.com/docs/api/model.html#Model.updateOne * @param {Object} doc - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions) - * @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](/docs/api/query.html#query_Query-lean) and the [Mongoose lean tutorial](/docs/tutorials/lean.html). + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) + * @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.lean()) and the [Mongoose lean tutorial](https://mongoosejs.com/docs/tutorials/lean.html). * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) - * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set. + * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set. * @param {Function} [callback] * @return {Query} * @api public @@ -855,9 +855,9 @@ Document.prototype.updateOne = function updateOne(doc, options, callback) { * * #### Valid options: * - * - same as in [Model.replaceOne](https://mongoosejs.com/docs/api/model.html#model_Model-replaceOne) + * - same as in [Model.replaceOne](https://mongoosejs.com/docs/api/model.html#Model.replaceOne()) * - * @see Model.replaceOne #model_Model-replaceOne + * @see Model.replaceOne https://mongoosejs.com/docs/api/model.html#Model.replaceOne() * @param {Object} doc * @param {Object} [options] * @param {Function} [callback] @@ -1008,7 +1008,7 @@ Document.prototype.overwrite = function overwrite(obj) { * @param {Any} val the value to set * @param {Schema|String|Number|Buffer|*} [type] optionally specify a type for "on-the-fly" attributes * @param {Object} [options] optionally specify options that modify the behavior of the set - * @param {Boolean} [options.merge=false] if true, setting a [nested path](/docs/subdocs.html#subdocuments-versus-nested-paths) will merge existing values rather than overwrite the whole object. So `doc.set('nested', { a: 1, b: 2 })` becomes `doc.set('nested.a', 1); doc.set('nested.b', 2);` + * @param {Boolean} [options.merge=false] if true, setting a [nested path](https://mongoosejs.com/docs/subdocs.html#subdocuments-versus-nested-paths) will merge existing values rather than overwrite the whole object. So `doc.set('nested', { a: 1, b: 2 })` becomes `doc.set('nested.a', 1); doc.set('nested.b', 2);` * @return {Document} this * @method $set * @memberOf Document @@ -1493,7 +1493,7 @@ function _isManuallyPopulatedArray(val, ref) { /** * Sets the value of a path, or many paths. - * Alias for [`.$set`](#document_Document-$set). + * Alias for [`.$set`](https://mongoosejs.com/docs/api/document.html#Document.prototype.$set()). * * #### Example: * @@ -2024,7 +2024,7 @@ Document.prototype.directModifiedPaths = function() { /** * Returns true if the given path is nullish or only contains empty objects. * Useful for determining whether this subdoc will get stripped out by the - * [minimize option](/docs/guide.html#minimize). + * [minimize option](https://mongoosejs.com/docs/guide.html#minimize). * * #### Example: * @@ -2205,7 +2205,7 @@ Document.prototype.isModified = function(paths, modifiedPaths) { }; /** - * Alias of [`.isModified`](#document_Document-isModified) + * Alias of [`.isModified`](https://mongoosejs.com/docs/api/document.html#Document.prototype.isModified()) * * @method $isModified * @memberOf Document @@ -2484,7 +2484,7 @@ Document.prototype.isDirectSelected = function isDirectSelected(path) { * * #### Note: * - * This method is called `pre` save and if a validation rule is violated, [save](#model_Model-save) is aborted and the error is returned to your `callback`. + * This method is called `pre` save and if a validation rule is violated, [save](https://mongoosejs.com/docs/api/model.html#Model.prototype.save()) is aborted and the error is returned to your `callback`. * * #### Example: * @@ -2548,7 +2548,7 @@ Document.prototype.validate = async function validate(pathsToValidate, options) }; /** - * Alias of [`.validate`](#document_Document-validate) + * Alias of [`.validate`](https://mongoosejs.com/docs/api/document.html#Document.prototype.validate()) * * @method $validate * @memberOf Document @@ -3194,8 +3194,8 @@ function _checkImmutableSubpaths(subdoc, schematype, priorVal) { } /** - * Saves this document by inserting a new document into the database if [document.isNew](#document_Document-isNew) is `true`, - * or sends an [updateOne](#document_Document-updateOne) operation **only** with the modifications to the database, it does not replace the whole document in the latter case. + * Saves this document by inserting a new document into the database if [document.isNew](https://mongoosejs.com/docs/api/document.html#Document.prototype.isNew()) is `true`, + * or sends an [updateOne](https://mongoosejs.com/docs/api/document.html#Document.prototype.updateOne()) operation **only** with the modifications to the database, it does not replace the whole document in the latter case. * * #### Example: * @@ -3211,20 +3211,20 @@ function _checkImmutableSubpaths(subdoc, schematype, priorVal) { * newProduct === product; // true * * @param {Object} [options] options optional options - * @param {Session} [options.session=null] the [session](https://www.mongodb.com/docs/manual/reference/server-sessions/) associated with this save operation. If not specified, defaults to the [document's associated session](#document_Document-$session). - * @param {Object} [options.safe] (DEPRECATED) overrides [schema's safe option](https://mongoosejs.com//docs/guide.html#safe). Use the `w` option instead. + * @param {Session} [options.session=null] the [session](https://www.mongodb.com/docs/manual/reference/server-sessions/) associated with this save operation. If not specified, defaults to the [document's associated session](https://mongoosejs.com/docs/api/document.html#Document.prototype.$session()). + * @param {Object} [options.safe] (DEPRECATED) overrides [schema's safe option](https://mongoosejs.com/docs/guide.html#safe). Use the `w` option instead. * @param {Boolean} [options.validateBeforeSave] set to false to save without validating. * @param {Boolean} [options.validateModifiedOnly=false] If `true`, Mongoose will only validate modified paths, as opposed to modified paths and `required` paths. - * @param {Number|String} [options.w] set the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/#w-option). Overrides the [schema-level `writeConcern` option](/docs/guide.html#writeConcern) - * @param {Boolean} [options.j] set to true for MongoDB to wait until this `save()` has been [journaled before resolving the returned promise](https://www.mongodb.com/docs/manual/reference/write-concern/#j-option). Overrides the [schema-level `writeConcern` option](/docs/guide.html#writeConcern) - * @param {Number} [options.wtimeout] sets a [timeout for the write concern](https://www.mongodb.com/docs/manual/reference/write-concern/#wtimeout). Overrides the [schema-level `writeConcern` option](/docs/guide.html#writeConcern). + * @param {Number|String} [options.w] set the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/#w-option). Overrides the [schema-level `writeConcern` option](https://mongoosejs.com/docs/guide.html#writeConcern) + * @param {Boolean} [options.j] set to true for MongoDB to wait until this `save()` has been [journaled before resolving the returned promise](https://www.mongodb.com/docs/manual/reference/write-concern/#j-option). Overrides the [schema-level `writeConcern` option](https://mongoosejs.com/docs/guide.html#writeConcern) + * @param {Number} [options.wtimeout] sets a [timeout for the write concern](https://www.mongodb.com/docs/manual/reference/write-concern/#wtimeout). Overrides the [schema-level `writeConcern` option](https://mongoosejs.com/docs/guide.html#writeConcern). * @param {Boolean} [options.checkKeys=true] the MongoDB driver prevents you from saving keys that start with '$' or contain '.' by default. Set this option to `false` to skip that check. See [restrictions on field names](https://www.mongodb.com/docs/manual/reference/limits/#Restrictions-on-Field-Names) - * @param {Boolean} [options.timestamps=true] if `false` and [timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this `save()`. + * @param {Boolean} [options.timestamps=true] if `false` and [timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this `save()`. * @param {Function} [fn] optional callback * @method save * @memberOf Document * @instance - * @throws {DocumentNotFoundError} if this [save updates an existing document](#document_Document-isNew) but the document doesn't exist in the database. For example, you will get this error if the document is [deleted between when you retrieved the document and when you saved it](documents.html#updating). + * @throws {DocumentNotFoundError} if this [save updates an existing document](https://mongoosejs.com/docs/api/document.html#Document.prototype.isNew()) but the document doesn't exist in the database. For example, you will get this error if the document is [deleted between when you retrieved the document and when you saved it](documents.html#updating). * @return {Promise|undefined} Returns undefined if used with callback or a Promise otherwise. * @api public * @see middleware https://mongoosejs.com/docs/middleware.html @@ -3752,7 +3752,7 @@ Document.prototype.$toObject = function(options, json) { * * doc.toObject({ getters: true }) * - * To apply these options to every document of your schema by default, set your [schemas](#schema_Schema) `toObject` option to the same argument. + * To apply these options to every document of your schema by default, set your [schemas](https://mongoosejs.com/docs/api/schema.html#Schema()) `toObject` option to the same argument. * * schema.set('toObject', { virtuals: true }) * @@ -3826,7 +3826,7 @@ Document.prototype.$toObject = function(options, json) { * doc.toObject({ hide: 'secret _id', transform: true }); // { name: 'Wreck-it Ralph' } * * If you pass a transform in `toObject()` options, Mongoose will apply the transform - * to [subdocuments](/docs/subdocs.html) in addition to the top-level document. + * to [subdocuments](https://mongoosejs.com/docs/subdocs.html) in addition to the top-level document. * Similarly, `transform: false` skips transforms for all subdocuments. * Note that this behavior is different for transforms defined in the schema: * if you define a transform in `schema.options.toObject.transform`, that transform @@ -3848,7 +3848,7 @@ Document.prototype.$toObject = function(options, json) { * * Transforms, like all of these options, are also available for `toJSON`. See [this guide to `JSON.stringify()`](https://thecodebarbarian.com/the-80-20-guide-to-json-stringify-in-javascript.html) to learn why `toJSON()` and `toObject()` are separate functions. * - * See [schema options](/docs/guide.html#toObject) for some more details. + * See [schema options](https://mongoosejs.com/docs/guide.html#toObject) for some more details. * * _During save, no custom options are applied to the document before being sent to the database._ * @@ -4130,20 +4130,20 @@ function omitDeselectedFields(self, json) { /** * The return value of this method is used in calls to [`JSON.stringify(doc)`](https://thecodebarbarian.com/the-80-20-guide-to-json-stringify-in-javascript#the-tojson-function). * - * This method accepts the same options as [Document#toObject](#document_Document-toObject). To apply the options to every document of your schema by default, set your [schemas](#schema_Schema) `toJSON` option to the same argument. + * This method accepts the same options as [Document#toObject](https://mongoosejs.com/docs/api/document.html#Document.prototype.toObject()). To apply the options to every document of your schema by default, set your [schemas](https://mongoosejs.com/docs/api/schema.html#Schema()) `toJSON` option to the same argument. * * schema.set('toJSON', { virtuals: true }); * * There is one difference between `toJSON()` and `toObject()` options. - * When you call `toJSON()`, the [`flattenMaps` option](./document.html#document_Document-toObject) defaults to `true`, because `JSON.stringify()` doesn't convert maps to objects by default. + * When you call `toJSON()`, the [`flattenMaps` option](https://mongoosejs.com/docs/api/document.html#Document.prototype.toObject()) defaults to `true`, because `JSON.stringify()` doesn't convert maps to objects by default. * When you call `toObject()`, the `flattenMaps` option is `false` by default. * - * See [schema options](/docs/guide.html#toJSON) for more information on setting `toJSON` option defaults. + * See [schema options](https://mongoosejs.com/docs/guide.html#toJSON) for more information on setting `toJSON` option defaults. * * @param {Object} options * @param {Boolean} [options.flattenMaps=true] if true, convert Maps to [POJOs](https://masteringjs.io/tutorials/fundamentals/pojo). Useful if you want to `JSON.stringify()` the result. * @return {Object} - * @see Document#toObject #document_Document-toObject + * @see Document#toObject https://mongoosejs.com/docs/api/document.html#Document.prototype.toObject() * @see JSON.stringify() in JavaScript https://thecodebarbarian.com/the-80-20-guide-to-json-stringify-in-javascript.html * @api public * @memberOf Document @@ -4179,7 +4179,7 @@ Document.prototype.parent = function() { }; /** - * Alias for [`parent()`](#document_Document-parent). If this document is a subdocument or populated + * Alias for [`parent()`](https://mongoosejs.com/docs/api/document.html#Document.prototype.parent()). If this document is a subdocument or populated * document, returns the document's parent. Returns `undefined` otherwise. * * @return {Document} @@ -4301,17 +4301,17 @@ Document.prototype.equals = function(doc) { * @param {Object} [match] Conditions for the population query * @param {Object} [options] Options for the population query (sort, etc) * @param {String} [options.path=null] The path to populate. - * @param {string|PopulateOptions} [options.populate=null] Recursively populate paths in the populated documents. See [deep populate docs](/docs/populate.html#deep-populate). + * @param {string|PopulateOptions} [options.populate=null] Recursively populate paths in the populated documents. See [deep populate docs](https://mongoosejs.com/docs/populate.html#deep-populate). * @param {boolean} [options.retainNullValues=false] by default, Mongoose removes null and undefined values from populated arrays. Use this option to make `populate()` retain `null` and `undefined` array entries. - * @param {boolean} [options.getters=false] if true, Mongoose will call any getters defined on the `localField`. By default, Mongoose gets the raw value of `localField`. For example, you would need to set this option to `true` if you wanted to [add a `lowercase` getter to your `localField`](/docs/schematypes.html#schematype-options). + * @param {boolean} [options.getters=false] if true, Mongoose will call any getters defined on the `localField`. By default, Mongoose gets the raw value of `localField`. For example, you would need to set this option to `true` if you wanted to [add a `lowercase` getter to your `localField`](https://mongoosejs.com/docs/schematypes.html#schematype-options). * @param {boolean} [options.clone=false] When you do `BlogPost.find().populate('author')`, blog posts with the same author will share 1 copy of an `author` doc. Enable this option to make Mongoose clone populated docs before assigning them. * @param {Object|Function} [options.match=null] Add an additional filter to the populate query. Can be a filter object containing [MongoDB query syntax](https://www.mongodb.com/docs/manual/tutorial/query-documents/), or a function that returns a filter object. * @param {Function} [options.transform=null] Function that Mongoose will call on every populated document that allows you to transform the populated document. * @param {Object} [options.options=null] Additional options like `limit` and `lean`. * @param {Function} [callback] Callback - * @see population /docs/populate.html - * @see Query#select #query_Query-select - * @see Model.populate #model_Model-populate + * @see population https://mongoosejs.com/docs/populate.html + * @see Query#select https://mongoosejs.com/docs/api/query.html#Query.prototype.select() + * @see Model.populate https://mongoosejs.com/docs/api/model.html#Model.populate() * @memberOf Document * @instance * @return {Promise|null} Returns a Promise if no `callback` is given. @@ -4455,7 +4455,7 @@ Document.prototype.populated = function(path, val, options) { }; /** - * Alias of [`.populated`](#document_Document-populated). + * Alias of [`.populated`](https://mongoosejs.com/docs/api/document.html#Document.prototype.populated()). * * @method $populated * @memberOf Document @@ -4520,7 +4520,7 @@ Document.prototype.$assertPopulated = function $assertPopulated(path, values) { * * @param {String|String[]} [path] Specific Path to depopulate. If unset, will depopulate all paths on the Document. Or multiple space-delimited paths. * @return {Document} this - * @see Document.populate #document_Document-populate + * @see Document.populate https://mongoosejs.com/docs/api/document.html#Document.prototype.populate() * @api public * @memberOf Document * @instance diff --git a/lib/error/index.js b/lib/error/index.js index a2c5fbebe69..6e31a83ee82 100644 --- a/lib/error/index.js +++ b/lib/error/index.js @@ -26,17 +26,17 @@ const MongooseError = require('./mongooseError'); * - `MongooseError`: general Mongoose error * - `CastError`: Mongoose could not convert a value to the type defined in the schema path. May be in a `ValidationError` class' `errors` property. * - `DivergentArrayError`: You attempted to `save()` an array that was modified after you loaded it with a `$elemMatch` or similar projection - * - `MissingSchemaError`: You tried to access a model with [`mongoose.model()`](mongoose.html#mongoose_Mongoose-model) that was not defined - * - `DocumentNotFoundError`: The document you tried to [`save()`](document.html#document_Document-save) was not found + * - `MissingSchemaError`: You tried to access a model with [`mongoose.model()`](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.model()) that was not defined + * - `DocumentNotFoundError`: The document you tried to [`save()`](https://mongoosejs.com/docs/api/document.html#Document.prototype.save()) was not found * - `ValidatorError`: error from an individual schema path's validator - * - `ValidationError`: error returned from [`validate()`](document.html#document_Document-validate) or [`validateSync()`](document.html#document_Document-validateSync). Contains zero or more `ValidatorError` instances in `.errors` property. + * - `ValidationError`: error returned from [`validate()`](https://mongoosejs.com/docs/api/document.html#Document.prototype.validate()) or [`validateSync()`](https://mongoosejs.com/docs/api/document.html#Document.prototype.validateSync()). Contains zero or more `ValidatorError` instances in `.errors` property. * - `MissingSchemaError`: You called `mongoose.Document()` without a schema - * - `ObjectExpectedError`: Thrown when you set a nested path to a non-object value with [strict mode set](/docs/guide.html#strict). + * - `ObjectExpectedError`: Thrown when you set a nested path to a non-object value with [strict mode set](https://mongoosejs.com/docs/guide.html#strict). * - `ObjectParameterError`: Thrown when you pass a non-object value to a function which expects an object as a paramter - * - `OverwriteModelError`: Thrown when you call [`mongoose.model()`](mongoose.html#mongoose_Mongoose-model) to re-define a model that was already defined. - * - `ParallelSaveError`: Thrown when you call [`save()`](model.html#model_Model-save) on a document when the same document instance is already saving. - * - `StrictModeError`: Thrown when you set a path that isn't the schema and [strict mode](/docs/guide.html#strict) is set to `throw`. - * - `VersionError`: Thrown when the [document is out of sync](/docs/guide.html#versionKey) + * - `OverwriteModelError`: Thrown when you call [`mongoose.model()`](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.model()) to re-define a model that was already defined. + * - `ParallelSaveError`: Thrown when you call [`save()`](https://mongoosejs.com/docs/api/model.html#Model.prototype.save()) on a document when the same document instance is already saving. + * - `StrictModeError`: Thrown when you set a path that isn't the schema and [strict mode](https://mongoosejs.com/docs/guide.html#strict) is set to `throw`. + * - `VersionError`: Thrown when the [document is out of sync](https://mongoosejs.com/docs/guide.html#versionKey) * * @api public * @property {String} name @@ -53,7 +53,7 @@ module.exports = exports = MongooseError; /** * The default built-in validator error messages. * - * @see Error.messages #error_messages_MongooseError-messages + * @see Error.messages https://mongoosejs.com/docs/api/error.html#Error.messages * @api public * @memberOf Error * @static @@ -90,7 +90,7 @@ MongooseError.DocumentNotFoundError = require('./notFound'); MongooseError.CastError = require('./cast'); /** - * An instance of this error class will be returned when [validation](/docs/validation.html) failed. + * An instance of this error class will be returned when [validation](https://mongoosejs.com/docs/validation.html) failed. * The `errors` property contains an object whose keys are the paths that failed and whose values are * instances of CastError or ValidationError. * @@ -139,7 +139,7 @@ MongooseError.ValidatorError = require('./validator'); /** * An instance of this error class will be returned when you call `save()` after * the document in the database was changed in a potentially unsafe way. See - * the [`versionKey` option](/docs/guide.html#versionKey) for more information. + * the [`versionKey` option](https://mongoosejs.com/docs/guide.html#versionKey) for more information. * * @api public * @memberOf Error @@ -150,7 +150,7 @@ MongooseError.VersionError = require('./version'); /** * An instance of this error class will be returned when you call `save()` multiple - * times on the same document in parallel. See the [FAQ](/docs/faq.html) for more + * times on the same document in parallel. See the [FAQ](https://mongoosejs.com/docs/faq.html) for more * information. * * @api public @@ -162,7 +162,7 @@ MongooseError.ParallelSaveError = require('./parallelSave'); /** * Thrown when a model with the given name was already registered on the connection. - * See [the FAQ about `OverwriteModelError`](/docs/faq.html#overwrite-model-error). + * See [the FAQ about `OverwriteModelError`](https://mongoosejs.com/docs/faq.html#overwrite-model-error). * * @api public * @memberOf Error diff --git a/lib/index.js b/lib/index.js index 681b5a456cf..c838b3ea2b5 100644 --- a/lib/index.js +++ b/lib/index.js @@ -54,7 +54,7 @@ const objectIdHexRegexp = /^[0-9A-Fa-f]{24}$/; * const m = new mongoose.Mongoose(); * * @api public - * @param {Object} options see [`Mongoose#set()` docs](/docs/api/mongoose.html#mongoose_Mongoose-set) + * @param {Object} options see [`Mongoose#set()` docs](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.set()) */ function Mongoose(options) { this.connections = []; @@ -192,25 +192,25 @@ Mongoose.prototype.setDriver = function setDriver(driver) { * - `allowDiskUse`: Set to `true` to set `allowDiskUse` to true to all aggregation operations by default. * - `applyPluginsToChildSchemas`: `true` by default. Set to false to skip applying global plugins to child schemas * - `applyPluginsToDiscriminators`: `false` by default. Set to true to apply global plugins to discriminator schemas. This typically isn't necessary because plugins are applied to the base schema and discriminators copy all middleware, methods, statics, and properties from the base schema. - * - `autoCreate`: Set to `true` to make Mongoose call [`Model.createCollection()`](/docs/api/model.html#model_Model-createCollection) automatically when you create a model with `mongoose.model()` or `conn.model()`. This is useful for testing transactions, change streams, and other features that require the collection to exist. + * - `autoCreate`: Set to `true` to make Mongoose call [`Model.createCollection()`](https://mongoosejs.com/docs/api/model.html#Model.createCollection()) automatically when you create a model with `mongoose.model()` or `conn.model()`. This is useful for testing transactions, change streams, and other features that require the collection to exist. * - `autoIndex`: `true` by default. Set to false to disable automatic index creation for all models associated with this Mongoose instance. * - `bufferCommands`: enable/disable mongoose's buffering mechanism for all connections and models * - `bufferTimeoutMS`: If bufferCommands is on, this option sets the maximum amount of time Mongoose buffering will wait before throwing an error. If not specified, Mongoose will use 10000 (10 seconds). * - `cloneSchemas`: `false` by default. Set to `true` to `clone()` all schemas before compiling into a model. * - `debug`: If `true`, prints the operations mongoose sends to MongoDB to the console. If a writable stream is passed, it will log to that stream, without colorization. If a callback function is passed, it will receive the collection name, the method name, then all arguments passed to the method. For example, if you wanted to replicate the default logging, you could output from the callback `Mongoose: ${collectionName}.${methodName}(${methodArgs.join(', ')})`. * - `id`: If `true`, adds a `id` virtual to all schemas unless overwritten on a per-schema basis. - * - `timestamps.createdAt.immutable`: `true` by default. If `false`, it will change the `createdAt` field to be [`immutable: false`](https://mongoosejs.com/docs/api/schematype.html#schematype_SchemaType-immutable) which means you can update the `createdAt` + * - `timestamps.createdAt.immutable`: `true` by default. If `false`, it will change the `createdAt` field to be [`immutable: false`](https://mongoosejs.com/docs/api/schematype.html#SchemaType.prototype.immutable) which means you can update the `createdAt` * - `maxTimeMS`: If set, attaches [maxTimeMS](https://www.mongodb.com/docs/manual/reference/operator/meta/maxTimeMS/) to every query * - `objectIdGetter`: `true` by default. Mongoose adds a getter to MongoDB ObjectId's called `_id` that returns `this` for convenience with populate. Set this to false to remove the getter. * - `overwriteModels`: Set to `true` to default to overwriting models with the same name when calling `mongoose.model()`, as opposed to throwing an `OverwriteModelError`. - * - `returnOriginal`: If `false`, changes the default `returnOriginal` option to `findOneAndUpdate()`, `findByIdAndUpdate`, and `findOneAndReplace()` to false. This is equivalent to setting the `new` option to `true` for `findOneAndX()` calls by default. Read our [`findOneAndUpdate()` tutorial](/docs/tutorials/findoneandupdate.html) for more information. - * - `runValidators`: `false` by default. Set to true to enable [update validators](/docs/validation.html#update-validators) for all validators by default. - * - `sanitizeFilter`: `false` by default. Set to true to enable the [sanitization of the query filters](/docs/api/mongoose.html#mongoose_Mongoose-sanitizeFilter) against query selector injection attacks by wrapping any nested objects that have a property whose name starts with `$` in a `$eq`. + * - `returnOriginal`: If `false`, changes the default `returnOriginal` option to `findOneAndUpdate()`, `findByIdAndUpdate`, and `findOneAndReplace()` to false. This is equivalent to setting the `new` option to `true` for `findOneAndX()` calls by default. Read our [`findOneAndUpdate()` tutorial](https://mongoosejs.com/docs/tutorials/findoneandupdate.html) for more information. + * - `runValidators`: `false` by default. Set to true to enable [update validators](https://mongoosejs.com/docs/validation.html#update-validators) for all validators by default. + * - `sanitizeFilter`: `false` by default. Set to true to enable the [sanitization of the query filters](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.sanitizeFilter()) against query selector injection attacks by wrapping any nested objects that have a property whose name starts with `$` in a `$eq`. * - `selectPopulatedPaths`: `true` by default. Set to false to opt out of Mongoose adding all fields that you `populate()` to your `select()`. The schema-level option `selectPopulatedPaths` overwrites this one. * - `strict`: `true` by default, may be `false`, `true`, or `'throw'`. Sets the default strict mode for schemas. - * - `strictQuery`: `false` by default. May be `false`, `true`, or `'throw'`. Sets the default [strictQuery](/docs/guide.html#strictQuery) mode for schemas. - * - `toJSON`: `{ transform: true, flattenDecimals: true }` by default. Overwrites default objects to [`toJSON()`](/docs/api/document.html#document_Document-toJSON), for determining how Mongoose documents get serialized by `JSON.stringify()` - * - `toObject`: `{ transform: true, flattenDecimals: true }` by default. Overwrites default objects to [`toObject()`](/docs/api/document.html#document_Document-toObject) + * - `strictQuery`: `false` by default. May be `false`, `true`, or `'throw'`. Sets the default [strictQuery](https://mongoosejs.com/docs/guide.html#strictQuery) mode for schemas. + * - `toJSON`: `{ transform: true, flattenDecimals: true }` by default. Overwrites default objects to [`toJSON()`](https://mongoosejs.com/docs/api/document.html#Document.prototype.toJSON()), for determining how Mongoose documents get serialized by `JSON.stringify()` + * - `toObject`: `{ transform: true, flattenDecimals: true }` by default. Overwrites default objects to [`toObject()`](https://mongoosejs.com/docs/api/document.html#Document.prototype.toObject()) * * @param {String|Object} key The name of the option or a object of multiple key-value pairs * @param {String|Function|Boolean} value The value of the option, unused if "key" is a object @@ -390,7 +390,7 @@ Mongoose.prototype.createConnection = function(uri, options) { * @param {Number} [options.family=0] Passed transparently to [Node.js' `dns.lookup()`](https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback) function. May be either `0`, `4`, or `6`. `4` means use IPv4 only, `6` means use IPv6 only, `0` means try both. * @param {Boolean} [options.autoCreate=false] Set to `true` to make Mongoose automatically call `createCollection()` on every model created on this connection. * @param {Function} [callback] - * @see Mongoose#createConnection /docs/api/mongoose.html#mongoose_Mongoose-createConnection + * @see Mongoose#createConnection https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.createConnection() * @api public * @return {Promise} resolves to `this` if connection succeeded */ @@ -434,7 +434,7 @@ Mongoose.prototype.disconnect = async function disconnect() { * * Calling `mongoose.startSession()` is equivalent to calling `mongoose.connection.startSession()`. * Sessions are scoped to a connection, so calling `mongoose.startSession()` - * starts a session on the [default mongoose connection](/docs/api/mongoose.html#mongoose_Mongoose-connection). + * starts a session on the [default mongoose connection](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.connection). * * @param {Object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/4.9/classes/MongoClient.html#startSession) * @param {Boolean} [options.causalConsistency=true] set to false to disable causal consistency @@ -708,7 +708,7 @@ Mongoose.prototype._applyPlugins = function(schema, options) { * @param {Function} fn plugin callback * @param {Object} [opts] optional options * @return {Mongoose} this - * @see plugins /docs/plugins.html + * @see plugins https://mongoosejs.com/docs/plugins.html * @api public */ @@ -720,7 +720,7 @@ Mongoose.prototype.plugin = function(fn, opts) { }; /** - * The Mongoose module's default connection. Equivalent to `mongoose.connections[0]`, see [`connections`](#mongoose_Mongoose-connections). + * The Mongoose module's default connection. Equivalent to `mongoose.connections[0]`, see [`connections`](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.connections). * * #### Example: * @@ -728,9 +728,9 @@ Mongoose.prototype.plugin = function(fn, opts) { * mongoose.connect(...); * mongoose.connection.on('error', cb); * - * This is the connection used by default for every model created using [mongoose.model](#index_Mongoose-model). + * This is the connection used by default for every model created using [mongoose.model](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.model()). * - * To create a new connection, use [`createConnection()`](#mongoose_Mongoose-createConnection). + * To create a new connection, use [`createConnection()`](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.createConnection()). * * @memberOf Mongoose * @instance @@ -752,7 +752,7 @@ Mongoose.prototype.__defineSetter__('connection', function(v) { /** * An array containing all [connections](connection.html) associated with this * Mongoose instance. By default, there is 1 connection. Calling - * [`createConnection()`](#mongoose_Mongoose-createConnection) adds a connection + * [`createConnection()`](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.createConnection()) adds a connection * to this array. * * #### Example: @@ -774,7 +774,7 @@ Mongoose.prototype.connections; /** * An integer containing the value of the next connection id. Calling - * [`createConnection()`](#mongoose_Mongoose-createConnection) increments + * [`createConnection()`](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.createConnection()) increments * this value. * * #### Example: @@ -821,7 +821,7 @@ Object.defineProperty(Mongoose.prototype, 'Collection', { }); /** - * The Mongoose [Connection](#connection_Connection) constructor + * The Mongoose [Connection](https://mongoosejs.com/docs/api/connection.html#Connection()) constructor * * @memberOf Mongoose * @instance @@ -872,7 +872,7 @@ Mongoose.prototype.version = pkg.version; Mongoose.prototype.Mongoose = Mongoose; /** - * The Mongoose [Schema](#schema_Schema) constructor + * The Mongoose [Schema](https://mongoosejs.com/docs/api/schema.html#Schema()) constructor * * #### Example: * @@ -887,7 +887,7 @@ Mongoose.prototype.Mongoose = Mongoose; Mongoose.prototype.Schema = Schema; /** - * The Mongoose [SchemaType](#schematype_SchemaType) constructor + * The Mongoose [SchemaType](https://mongoosejs.com/docs/api/schematype.html#SchemaType()) constructor * * @method SchemaType * @api public @@ -903,14 +903,14 @@ Mongoose.prototype.SchemaType = SchemaType; * _Alias of mongoose.Schema.Types for backwards compatibility._ * * @property SchemaTypes - * @see Schema.SchemaTypes /docs/schematypes.html + * @see Schema.SchemaTypes https://mongoosejs.com/docs/schematypes.html * @api public */ Mongoose.prototype.SchemaTypes = Schema.Types; /** - * The Mongoose [VirtualType](#virtualtype_VirtualType) constructor + * The Mongoose [VirtualType](https://mongoosejs.com/docs/api/virtualtype.html#VirtualType()) constructor * * @method VirtualType * @api public @@ -928,14 +928,14 @@ Mongoose.prototype.VirtualType = VirtualType; * * #### Types: * - * - [Array](/docs/schematypes.html#arrays) - * - [Buffer](/docs/schematypes.html#buffers) - * - [Embedded](/docs/schematypes.html#schemas) - * - [DocumentArray](/docs/api/documentarraypath.html) - * - [Decimal128](/docs/api/mongoose.html#mongoose_Mongoose-Decimal128) - * - [ObjectId](/docs/schematypes.html#objectids) - * - [Map](/docs/schematypes.html#maps) - * - [Subdocument](/docs/schematypes.html#schemas) + * - [Array](https://mongoosejs.com/docs/schematypes.html#arrays) + * - [Buffer](https://mongoosejs.com/docs/schematypes.html#buffers) + * - [Embedded](https://mongoosejs.com/docs/schematypes.html#schemas) + * - [DocumentArray](https://mongoosejs.com/docs/api/documentarraypath.html) + * - [Decimal128](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.Decimal128) + * - [ObjectId](https://mongoosejs.com/docs/schematypes.html#objectids) + * - [Map](https://mongoosejs.com/docs/schematypes.html#maps) + * - [Subdocument](https://mongoosejs.com/docs/schematypes.html#schemas) * * Using this exposed access to the `ObjectId` type, we can construct ids on demand. * @@ -949,7 +949,7 @@ Mongoose.prototype.VirtualType = VirtualType; Mongoose.prototype.Types = Types; /** - * The Mongoose [Query](#query_Query) constructor. + * The Mongoose [Query](https://mongoosejs.com/docs/api/query.html#Query()) constructor. * * @method Query * @api public @@ -958,7 +958,7 @@ Mongoose.prototype.Types = Types; Mongoose.prototype.Query = Query; /** - * The Mongoose [Model](#model_Model) constructor. + * The Mongoose [Model](https://mongoosejs.com/docs/api/model.html#Model()) constructor. * * @method Model * @api public @@ -967,7 +967,7 @@ Mongoose.prototype.Query = Query; Mongoose.prototype.Model = Model; /** - * The Mongoose [Document](/docs/api/document.html#Document) constructor. + * The Mongoose [Document](https://mongoosejs.com/docs/api/document.html#Document()) constructor. * * @method Document * @api public @@ -986,7 +986,7 @@ Mongoose.prototype.Document = Document; Mongoose.prototype.DocumentProvider = require('./document_provider'); /** - * The Mongoose ObjectId [SchemaType](/docs/schematypes.html). Used for + * The Mongoose ObjectId [SchemaType](https://mongoosejs.com/docs/schematypes.html). Used for * declaring paths in your schema that should be * [MongoDB ObjectIds](https://www.mongodb.com/docs/manual/reference/method/ObjectId/). * Do not use this to create a new ObjectId instance, use `mongoose.Types.ObjectId` @@ -1071,7 +1071,7 @@ Mongoose.prototype.syncIndexes = function(options) { }; /** - * The Mongoose Decimal128 [SchemaType](/docs/schematypes.html). Used for + * The Mongoose Decimal128 [SchemaType](https://mongoosejs.com/docs/schematypes.html). Used for * declaring paths in your schema that should be * [128-bit decimal floating points](https://thecodebarbarian.com/a-nodejs-perspective-on-mongodb-34-decimal.html). * Do not use this to create a new Decimal128 instance, use `mongoose.Types.Decimal128` @@ -1088,7 +1088,7 @@ Mongoose.prototype.syncIndexes = function(options) { Mongoose.prototype.Decimal128 = SchemaTypes.Decimal128; /** - * The Mongoose Mixed [SchemaType](/docs/schematypes.html). Used for + * The Mongoose Mixed [SchemaType](https://mongoosejs.com/docs/schematypes.html). Used for * declaring paths in your schema that Mongoose's change tracking, casting, * and validation should ignore. * @@ -1103,7 +1103,7 @@ Mongoose.prototype.Decimal128 = SchemaTypes.Decimal128; Mongoose.prototype.Mixed = SchemaTypes.Mixed; /** - * The Mongoose Date [SchemaType](/docs/schematypes.html). + * The Mongoose Date [SchemaType](https://mongoosejs.com/docs/schematypes.html). * * #### Example: * @@ -1117,7 +1117,7 @@ Mongoose.prototype.Mixed = SchemaTypes.Mixed; Mongoose.prototype.Date = SchemaTypes.Date; /** - * The Mongoose Number [SchemaType](/docs/schematypes.html). Used for + * The Mongoose Number [SchemaType](https://mongoosejs.com/docs/schematypes.html). Used for * declaring paths in your schema that Mongoose should cast to numbers. * * #### Example: @@ -1133,7 +1133,7 @@ Mongoose.prototype.Date = SchemaTypes.Date; Mongoose.prototype.Number = SchemaTypes.Number; /** - * The [MongooseError](#error_MongooseError) constructor. + * The [MongooseError](https://mongoosejs.com/docs/api/error.html#Error()) constructor. * * @method Error * @api public @@ -1143,7 +1143,7 @@ Mongoose.prototype.Error = require('./error/index'); /** * Mongoose uses this function to get the current time when setting - * [timestamps](/docs/guide.html#timestamps). You may stub out this function + * [timestamps](https://mongoosejs.com/docs/guide.html#timestamps). You may stub out this function * using a tool like [Sinon](https://www.npmjs.com/package/sinon) for testing. * * @method now diff --git a/lib/model.js b/lib/model.js index 5a09efac493..4aa4e79cc2f 100644 --- a/lib/model.js +++ b/lib/model.js @@ -81,12 +81,12 @@ const saveToObjectOptions = Object.assign({}, internalToObjectOptions, { /** * A Model is a class that's your primary tool for interacting with MongoDB. - * An instance of a Model is called a [Document](/docs/api/document.html#Document). + * An instance of a Model is called a [Document](https://mongoosejs.com/docs/api/document.html#Document). * * In Mongoose, the term "Model" refers to subclasses of the `mongoose.Model` * class. You should not use the `mongoose.Model` class directly. The - * [`mongoose.model()`](/docs/api/mongoose.html#mongoose_Mongoose-model) and - * [`connection.model()`](/docs/api/connection.html#connection_Connection-model) functions + * [`mongoose.model()`](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.model()) and + * [`connection.model()`](https://mongoosejs.com/docs/api/connection.html#Connection.prototype.model()) functions * create subclasses of `mongoose.Model` as shown below. * * #### Example: @@ -102,7 +102,7 @@ const saveToObjectOptions = Object.assign({}, internalToObjectOptions, { * const userFromDb = await UserModel.findOne({ name: 'Foo' }); * * @param {Object} doc values for initial set - * @param {Object} [fields] optional object containing the fields that were selected in the query which returned this document. You do **not** need to set this parameter to ensure Mongoose handles your [query projection](/docs/api/query.html#query_Query-select). + * @param {Object} [fields] optional object containing the fields that were selected in the query which returned this document. You do **not** need to set this parameter to ensure Mongoose handles your [query projection](https://mongoosejs.com/docs/api/query.html#Query.prototype.select()). * @param {Boolean} [skipId=false] optional boolean. If true, mongoose doesn't add an `_id` field to the document. * @inherits Document https://mongoosejs.com/docs/api/document.html * @event `error`: If listening to this event, 'error' is emitted when a document was saved and an `error` occurred. If not listening, the event bubbles to the connection used to create this Model. @@ -459,8 +459,8 @@ function generateVersionError(doc, modifiedPaths) { } /** - * Saves this document by inserting a new document into the database if [document.isNew](/docs/api/document.html#document_Document-isNew) is `true`, - * or sends an [updateOne](/docs/api/document.html#document_Document-updateOne) operation with just the modified paths if `isNew` is `false`. + * Saves this document by inserting a new document into the database if [document.isNew](https://mongoosejs.com/docs/api/document.html#Document.prototype.isNew) is `true`, + * or sends an [updateOne](https://mongoosejs.com/docs/api/document.html#Document.prototype.updateOne()) operation with just the modified paths if `isNew` is `false`. * * #### Example: * @@ -476,16 +476,16 @@ function generateVersionError(doc, modifiedPaths) { * newProduct === product; // true * * @param {Object} [options] options optional options - * @param {Session} [options.session=null] the [session](https://www.mongodb.com/docs/manual/reference/server-sessions/) associated with this save operation. If not specified, defaults to the [document's associated session](/docs/api/document.html#document_Document-$session). - * @param {Object} [options.safe] (DEPRECATED) overrides [schema's safe option](https://mongoosejs.com//docs/guide.html#safe). Use the `w` option instead. + * @param {Session} [options.session=null] the [session](https://www.mongodb.com/docs/manual/reference/server-sessions/) associated with this save operation. If not specified, defaults to the [document's associated session](https://mongoosejs.com/docs/api/document.html#Document.prototype.session()). + * @param {Object} [options.safe] (DEPRECATED) overrides [schema's safe option](https://mongoosejs.com/docs/guide.html#safe). Use the `w` option instead. * @param {Boolean} [options.validateBeforeSave] set to false to save without validating. * @param {Boolean} [options.validateModifiedOnly=false] if `true`, Mongoose will only validate modified paths, as opposed to modified paths and `required` paths. - * @param {Number|String} [options.w] set the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/#w-option). Overrides the [schema-level `writeConcern` option](/docs/guide.html#writeConcern) - * @param {Boolean} [options.j] set to true for MongoDB to wait until this `save()` has been [journaled before resolving the returned promise](https://www.mongodb.com/docs/manual/reference/write-concern/#j-option). Overrides the [schema-level `writeConcern` option](/docs/guide.html#writeConcern) - * @param {Number} [options.wtimeout] sets a [timeout for the write concern](https://www.mongodb.com/docs/manual/reference/write-concern/#wtimeout). Overrides the [schema-level `writeConcern` option](/docs/guide.html#writeConcern). - * @param {Boolean} [options.checkKeys=true] the MongoDB driver prevents you from saving keys that start with '$' or contain '.' by default. Set this option to `false` to skip that check. See [restrictions on field names](https://docs.mongodb.com/manual/reference/limits/#Restrictions-on-Field-Names) - * @param {Boolean} [options.timestamps=true] if `false` and [timestamps](./guide.html#timestamps) are enabled, skip timestamps for this `save()`. - * @throws {DocumentNotFoundError} if this [save updates an existing document](api/document.html#document_Document-isNew) but the document doesn't exist in the database. For example, you will get this error if the document is [deleted between when you retrieved the document and when you saved it](documents.html#updating). + * @param {Number|String} [options.w] set the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/#w-option). Overrides the [schema-level `writeConcern` option](https://mongoosejs.com/docs/guide.html#writeConcern) + * @param {Boolean} [options.j] set to true for MongoDB to wait until this `save()` has been [journaled before resolving the returned promise](https://www.mongodb.com/docs/manual/reference/write-concern/#j-option). Overrides the [schema-level `writeConcern` option](https://mongoosejs.com/docs/guide.html#writeConcern) + * @param {Number} [options.wtimeout] sets a [timeout for the write concern](https://www.mongodb.com/docs/manual/reference/write-concern/#wtimeout). Overrides the [schema-level `writeConcern` option](https://mongoosejs.com/docs/guide.html#writeConcern). + * @param {Boolean} [options.checkKeys=true] the MongoDB driver prevents you from saving keys that start with '$' or contain '.' by default. Set this option to `false` to skip that check. See [restrictions on field names](https://docs.mongodb.com/manual/reference/limits/#mongodb-limit-Restrictions-on-Field-Names) + * @param {Boolean} [options.timestamps=true] if `false` and [timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this `save()`. + * @throws {DocumentNotFoundError} if this [save updates an existing document](https://mongoosejs.com/docs/api/document.html#Document.prototype.isNew) but the document doesn't exist in the database. For example, you will get this error if the document is [deleted between when you retrieved the document and when you saved it](documents.html#updating). * @return {Promise} * @api public * @see middleware https://mongoosejs.com/docs/middleware.html @@ -1102,7 +1102,7 @@ Model.prototype.$model = function $model(name) { * - `findOne()` * * @param {Object} filter - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions) + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) * @return {Query} */ @@ -1249,8 +1249,8 @@ for (const i in EventEmitter.prototype) { * unless [`autoIndex`](https://mongoosejs.com/docs/guide.html#autoIndex) is turned off. * * Mongoose calls this function automatically when a model is created using - * [`mongoose.model()`](/docs/api/mongoose.html#mongoose_Mongoose-model) or - * [`connection.model()`](/docs/api/connection.html#connection_Connection-model), so you + * [`mongoose.model()`](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.model()) or + * [`connection.model()`](https://mongoosejs.com/docs/api/connection.html#Connection.prototype.model()), so you * don't need to call `init()` to trigger index builds. * * However, you _may_ need to call `init()` to get back a promise that will resolve when your indexes are finished. @@ -1588,7 +1588,7 @@ async function _dropIndexes(toDrop, collection) { /** * Lists the indexes currently defined in MongoDB. This may or may not be * the same as the indexes defined in your schema depending on whether you - * use the [`autoIndex` option](/docs/guide.html#autoIndex) and if you + * use the [`autoIndex` option](https://mongoosejs.com/docs/guide.html#autoIndex) and if you * build indexes manually. * * @return {Promise} @@ -1957,10 +1957,10 @@ Model.translateAliases = function translateAliases(fields) { * #### Note: * * This function triggers `deleteOne` query hooks. Read the - * [middleware docs](/docs/middleware.html#naming) to learn more. + * [middleware docs](https://mongoosejs.com/docs/middleware.html#naming) to learn more. * * @param {Object} conditions - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions) + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) * @return {Query} * @api public */ @@ -1991,10 +1991,10 @@ Model.deleteOne = function deleteOne(conditions, options) { * #### Note: * * This function triggers `deleteMany` query hooks. Read the - * [middleware docs](/docs/middleware.html#naming) to learn more. + * [middleware docs](https://mongoosejs.com/docs/middleware.html#naming) to learn more. * * @param {Object} conditions - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions) + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) * @return {Query} * @api public */ @@ -2016,7 +2016,7 @@ Model.deleteMany = function deleteMany(conditions, options) { * Finds documents. * * Mongoose casts the `filter` to match the model's schema before the command is sent. - * See our [query casting tutorial](/docs/tutorials/query_casting.html) for + * See our [query casting tutorial](https://mongoosejs.com/docs/tutorials/query_casting.html) for * more information on how Mongoose casts `filter`. * * #### Example: @@ -2034,11 +2034,11 @@ Model.deleteMany = function deleteMany(conditions, options) { * await MyModel.find({ name: /john/i }, null, { skip: 10 }).exec(); * * @param {Object|ObjectId} filter - * @param {Object|String|String[]} [projection] optional fields to return, see [`Query.prototype.select()`](https://mongoosejs.com/docs/api/query.html#query_Query-select) - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions) + * @param {Object|String|String[]} [projection] optional fields to return, see [`Query.prototype.select()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.select()) + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) * @return {Query} - * @see field selection #query_Query-select - * @see query casting /docs/tutorials/query_casting.html + * @see field selection https://mongoosejs.com/docs/api/query.html#Query.prototype.select() + * @see query casting https://mongoosejs.com/docs/tutorials/query_casting.html * @api public */ @@ -2080,11 +2080,11 @@ Model.find = function find(conditions, projection, options) { * await Adventure.findById(id, 'name length').exec(); * * @param {Any} id value of `_id` to query by - * @param {Object|String|String[]} [projection] optional fields to return, see [`Query.prototype.select()`](#query_Query-select) - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions) + * @param {Object|String|String[]} [projection] optional fields to return, see [`Query.prototype.select()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.select()) + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) * @return {Query} - * @see field selection #query_Query-select - * @see lean queries /docs/tutorials/lean.html + * @see field selection https://mongoosejs.com/docs/api/query.html#Query.prototype.select() + * @see lean queries https://mongoosejs.com/docs/tutorials/lean.html * @see findById in Mongoose https://masteringjs.io/tutorials/mongoose/find-by-id * @api public */ @@ -2122,11 +2122,11 @@ Model.findById = function findById(id, projection, options) { * await Adventure.findOne({ country: 'Croatia' }, 'name length').exec(); * * @param {Object} [conditions] - * @param {Object|String|String[]} [projection] optional fields to return, see [`Query.prototype.select()`](#query_Query-select) - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions) + * @param {Object|String|String[]} [projection] optional fields to return, see [`Query.prototype.select()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.select()) + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) * @return {Query} - * @see field selection #query_Query-select - * @see lean queries /docs/tutorials/lean.html + * @see field selection https://mongoosejs.com/docs/api/query.html#Query.prototype.select() + * @see lean queries https://mongoosejs.com/docs/tutorials/lean.html * @api public */ @@ -2176,7 +2176,7 @@ Model.estimatedDocumentCount = function estimatedDocumentCount(options) { * }); * * If you want to count all documents in a large collection, - * use the [`estimatedDocumentCount()` function](#model_Model-estimatedDocumentCount) + * use the [`estimatedDocumentCount()` function](https://mongoosejs.com/docs/api/model.html#Model.estimatedDocumentCount()) * instead. If you call `countDocuments({})`, MongoDB will always execute * a full collection scan and **not** use any indexes. * @@ -2212,8 +2212,8 @@ Model.countDocuments = function countDocuments(conditions, options) { * Counts number of documents that match `filter` in a database collection. * * This method is deprecated. If you want to count the number of documents in - * a collection, e.g. `count({})`, use the [`estimatedDocumentCount()` function](#model_Model-estimatedDocumentCount) - * instead. Otherwise, use the [`countDocuments()`](#model_Model-countDocuments) function instead. + * a collection, e.g. `count({})`, use the [`estimatedDocumentCount()` function](https://mongoosejs.com/docs/api/model.html#Model.estimatedDocumentCount()) + * instead. Otherwise, use the [`countDocuments()`](https://mongoosejs.com/docs/api/model.html#Model.countDocuments()) function instead. * * #### Example: * @@ -2305,7 +2305,7 @@ Model.where = function where(path, val) { * @method $where * @memberOf Model * @return {Query} - * @see Query.$where #query_Query-%24where + * @see Query.$where https://mongoosejs.com/docs/api/query.html#Query.prototype.$where * @api public */ @@ -2353,24 +2353,24 @@ Model.$where = function $where() { * * @param {Object} [conditions] * @param {Object} [update] - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions) + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) * @param {String} [options.returnDocument='before'] Has two possible values, `'before'` and `'after'`. By default, it will return the document before the update was applied. - * @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](/docs/api/query.html#query_Query-lean) and [the Mongoose lean tutorial](/docs/tutorials/lean.html). - * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html). + * @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.lean()) and [the Mongoose lean tutorial](https://mongoosejs.com/docs/tutorials/lean.html). + * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html). * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) - * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set. - * @param {Boolean} [options.overwrite=false] By default, if you don't include any [update operators](https://www.mongodb.com/docs/manual/reference/operator/update/) in `update`, Mongoose will wrap `update` in `$set` for you. This prevents you from accidentally overwriting the document. This option tells Mongoose to skip adding `$set`. An alternative to this would be using [Model.findOneAndReplace(conditions, update, options, callback)](#model_Model-findOneAndReplace). + * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set. + * @param {Boolean} [options.overwrite=false] By default, if you don't include any [update operators](https://www.mongodb.com/docs/manual/reference/operator/update/) in `update`, Mongoose will wrap `update` in `$set` for you. This prevents you from accidentally overwriting the document. This option tells Mongoose to skip adding `$set`. An alternative to this would be using [Model.findOneAndReplace(conditions, update, options, callback)](https://mongoosejs.com/docs/api/model.html#Model.findOneAndReplace()). * @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document - * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select) + * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.select()) * @param {Boolean} [options.new=false] if true, return the modified document rather than the original * @param {Object|String} [options.fields] Field selection. Equivalent to `.select(fields).findOneAndUpdate()` * @param {Number} [options.maxTimeMS] puts a time limit on the query - requires mongodb >= 2.6.0 * @param {Object|String} [options.sort] if multiple docs are found by the conditions, sets the sort order to choose which doc to update. - * @param {Boolean} [options.runValidators] if true, runs [update validators](/docs/validation.html#update-validators) on this command. Update validators validate the update operation against the model's schema + * @param {Boolean} [options.runValidators] if true, runs [update validators](https://mongoosejs.com/docs/validation.html#update-validators) on this command. Update validators validate the update operation against the model's schema * @param {Boolean} [options.setDefaultsOnInsert=true] If `setDefaultsOnInsert` and `upsert` are true, mongoose will apply the [defaults](https://mongoosejs.com/docs/defaults.html) specified in the model's schema if a new document is created * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html) * @return {Query} - * @see Tutorial /docs/tutorials/findoneandupdate.html + * @see Tutorial https://mongoosejs.com/docs/tutorials/findoneandupdate.html * @see mongodb https://www.mongodb.com/docs/manual/reference/command/findAndModify/ * @api public */ @@ -2473,22 +2473,22 @@ function _decorateUpdateWithVersionKey(update, options, versionKey) { * * @param {Object|Number|String} id value of `_id` to query by * @param {Object} [update] - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions) + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) * @param {String} [options.returnDocument='before'] Has two possible values, `'before'` and `'after'`. By default, it will return the document before the update was applied. - * @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](/docs/api/query.html#query_Query-lean) and [the Mongoose lean tutorial](/docs/tutorials/lean.html). - * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html). + * @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.lean()) and [the Mongoose lean tutorial](https://mongoosejs.com/docs/tutorials/lean.html). + * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html). * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) - * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set. - * @param {Boolean} [options.overwrite=false] By default, if you don't include any [update operators](https://www.mongodb.com/docs/manual/reference/operator/update/) in `update`, Mongoose will wrap `update` in `$set` for you. This prevents you from accidentally overwriting the document. This option tells Mongoose to skip adding `$set`. An alternative to this would be using [Model.findOneAndReplace({ _id: id }, update, options)](#model_Model-findOneAndReplace). + * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set. + * @param {Boolean} [options.overwrite=false] By default, if you don't include any [update operators](https://www.mongodb.com/docs/manual/reference/operator/update/) in `update`, Mongoose will wrap `update` in `$set` for you. This prevents you from accidentally overwriting the document. This option tells Mongoose to skip adding `$set`. An alternative to this would be using [Model.findOneAndReplace({ _id: id }, update, options)](https://mongoosejs.com/docs/api/model.html#Model.findOneAndReplace()). * @param {Object|String} [options.sort] if multiple docs are found by the conditions, sets the sort order to choose which doc to update. - * @param {Boolean} [options.runValidators] if true, runs [update validators](/docs/validation.html#update-validators) on this command. Update validators validate the update operation against the model's schema + * @param {Boolean} [options.runValidators] if true, runs [update validators](https://mongoosejs.com/docs/validation.html#update-validators) on this command. Update validators validate the update operation against the model's schema * @param {Boolean} [options.setDefaultsOnInsert=true] If `setDefaultsOnInsert` and `upsert` are true, mongoose will apply the [defaults](https://mongoosejs.com/docs/defaults.html) specified in the model's schema if a new document is created * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html) * @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document * @param {Boolean} [options.new=false] if true, return the modified document rather than the original * @param {Object|String} [options.select] sets the document fields to return. * @return {Query} - * @see Model.findOneAndUpdate #model_Model-findOneAndUpdate + * @see Model.findOneAndUpdate https://mongoosejs.com/docs/api/model.html#Model.findOneAndUpdate() * @see mongodb https://www.mongodb.com/docs/manual/reference/command/findAndModify/ * @api public */ @@ -2539,10 +2539,10 @@ Model.findByIdAndUpdate = function(id, update, options) { * await doc.save(); * * @param {Object} conditions - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions) + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) - * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select) - * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html). + * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.select()) + * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html). * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html) * @param {Object|String} [options.sort] if multiple docs are found by the conditions, sets the sort order to choose which doc to update. * @param {Object|String} [options.select] sets the document fields to return. @@ -2580,10 +2580,10 @@ Model.findOneAndDelete = function(conditions, options) { * - `findOneAndDelete()` * * @param {Object|Number|String} id value of `_id` to query by - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions) + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) * @return {Query} - * @see Model.findOneAndRemove #model_Model-findOneAndRemove + * @see Model.findOneAndRemove https://mongoosejs.com/docs/api/model.html#Model.findOneAndRemove() * @see mongodb https://www.mongodb.com/docs/manual/reference/command/findAndModify/ */ @@ -2614,13 +2614,13 @@ Model.findByIdAndDelete = function(id, options) { * * @param {Object} filter Replace the first document that matches this filter * @param {Object} [replacement] Replace with this document - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions) + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) * @param {String} [options.returnDocument='before'] Has two possible values, `'before'` and `'after'`. By default, it will return the document before the update was applied. - * @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](/docs/api/query.html#query_Query-lean) and [the Mongoose lean tutorial](/docs/tutorials/lean.html). - * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html). + * @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.lean()) and [the Mongoose lean tutorial](https://mongoosejs.com/docs/tutorials/lean.html). + * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html). * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) - * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set. - * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select) + * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set. + * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.select()) * @param {Object|String} [options.sort] if multiple docs are found by the conditions, sets the sort order to choose which doc to update. * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html) * @param {Object|String} [options.select] sets the document fields to return. @@ -2674,10 +2674,10 @@ Model.findOneAndReplace = function(filter, replacement, options) { * await doc.save(); * * @param {Object} conditions - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions) - * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html). + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) + * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html). * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) - * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select) + * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.select()) * @param {Object|String} [options.sort] if multiple docs are found by the conditions, sets the sort order to choose which doc to update. * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html) * @param {Object|String} [options.select] sets the document fields to return. @@ -2722,15 +2722,15 @@ Model.findOneAndRemove = function(conditions, options) { * A.findByIdAndRemove() // returns Query * * @param {Object|Number|String} id value of `_id` to query by - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions) + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) - * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html). - * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select) + * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html). + * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.select()) * @param {Object|String} [options.sort] if multiple docs are found by the conditions, sets the sort order to choose which doc to update. * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html) * @param {Object|String} [options.select] sets the document fields to return. * @return {Query} - * @see Model.findOneAndRemove #model_Model-findOneAndRemove + * @see Model.findOneAndRemove https://mongoosejs.com/docs/api/model.html#Model.findOneAndRemove() * @see mongodb https://www.mongodb.com/docs/manual/reference/command/findAndModify/ */ @@ -2767,7 +2767,7 @@ Model.findByIdAndRemove = function(id, options) { * await Character.create([{ name: 'Jean-Luc Picard' }], { session }); * * @param {Array|Object} docs Documents to insert, as a spread or array - * @param {Object} [options] Options passed down to `save()`. To specify `options`, `docs` **must** be an array, not a spread. See [Model.save](#model_Model-save) for available options. + * @param {Object} [options] Options passed down to `save()`. To specify `options`, `docs` **must** be an array, not a spread. See [Model.save](https://mongoosejs.com/docs/api/model.html#Model.prototype.save()) for available options. * @return {Promise} * @api public */ @@ -2808,7 +2808,7 @@ Model.create = async function create(doc, options) { // to use a spread to specify options, see gh-7535 utils.warn('WARNING: to pass a `session` to `Model.create()` in ' + 'Mongoose, you **must** pass an array as the first argument. See: ' + - 'https://mongoosejs.com/docs/api/model.html#model_Model-create'); + 'https://mongoosejs.com/docs/api/model.html#Model.create()'); } } @@ -3240,7 +3240,7 @@ function _setIsNew(doc, val) { * * This function does **not** trigger any middleware, neither `save()`, nor `update()`. * If you need to trigger - * `save()` middleware for every document use [`create()`](#model_Model-create) instead. + * `save()` middleware for every document use [`create()`](https://mongoosejs.com/docs/api/model.html#Model.create()) instead. * * #### Example: * @@ -3302,13 +3302,13 @@ function _setIsNew(doc, val) { * @param {Boolean} [ops.replaceOne.upsert=false] If true, insert a doc if no documents match `filter` * @param {Object} [options] * @param {Boolean} [options.ordered=true] If true, execute writes in order and stop at the first error. If false, execute writes in parallel and continue until all writes have either succeeded or errored. - * @param {ClientSession} [options.session=null] The session associated with this bulk write. See [transactions docs](/docs/transactions.html). - * @param {String|number} [options.w=1] The [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/). See [`Query#w()`](/docs/api/query.html#query_Query-w) for more information. + * @param {ClientSession} [options.session=null] The session associated with this bulk write. See [transactions docs](https://mongoosejs.com/docs/transactions.html). + * @param {String|number} [options.w=1] The [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/). See [`Query#w()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.w()) for more information. * @param {number} [options.wtimeout=null] The [write concern timeout](https://www.mongodb.com/docs/manual/reference/write-concern/#wtimeout). * @param {Boolean} [options.j=true] If false, disable [journal acknowledgement](https://www.mongodb.com/docs/manual/reference/write-concern/#j-option) * @param {Boolean} [options.skipValidation=false] Set to true to skip Mongoose schema validation on bulk write operations. Mongoose currently runs validation on `insertOne` and `replaceOne` operations by default. * @param {Boolean} [options.bypassDocumentValidation=false] If true, disable [MongoDB server-side schema validation](https://www.mongodb.com/docs/manual/core/schema-validation/) for all writes in this bulk. - * @param {Boolean} [options.strict=null] Overwrites the [`strict` option](/docs/guide.html#strict) on schema. If false, allows filtering and writing fields not defined in the schema for all writes in this bulk. + * @param {Boolean} [options.strict=null] Overwrites the [`strict` option](https://mongoosejs.com/docs/guide.html#strict) on schema. If false, allows filtering and writing fields not defined in the schema for all writes in this bulk. * @return {Promise} resolves to a [`BulkWriteOpResult`](https://mongodb.github.io/node-mongodb-native/4.9/classes/BulkWriteResult.html) if the operation succeeds * @api public */ @@ -3405,8 +3405,8 @@ Model.bulkWrite = async function bulkWrite(ops, options) { * @param {Array} documents * @param {Object} [options] options passed to the underlying `bulkWrite()` * @param {Boolean} [options.timestamps] defaults to `null`, when set to false, mongoose will not add/update timestamps to the documents. - * @param {ClientSession} [options.session=null] The session associated with this bulk write. See [transactions docs](/docs/transactions.html). - * @param {String|number} [options.w=1] The [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/). See [`Query#w()`](/docs/api/query.html#query_Query-w) for more information. + * @param {ClientSession} [options.session=null] The session associated with this bulk write. See [transactions docs](https://mongoosejs.com/docs/transactions.html). + * @param {String|number} [options.w=1] The [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/). See [`Query#w()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.w()) for more information. * @param {number} [options.wtimeout=null] The [write concern timeout](https://www.mongodb.com/docs/manual/reference/write-concern/#wtimeout). * @param {Boolean} [options.j=true] If false, disable [journal acknowledgement](https://www.mongodb.com/docs/manual/reference/write-concern/#j-option) * @@ -3734,11 +3734,11 @@ Model.hydrate = function(obj, projection, options) { * * @param {Object} filter * @param {Object|Array} update - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions) + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) * @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document - * @param {Object} [options.writeConcern=null] sets the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](/docs/guide.html#writeConcern) - * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Does nothing if schema-level timestamps are not set. + * @param {Object} [options.writeConcern=null] sets the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](https://mongoosejs.com/docs/guide.html#writeConcern) + * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Does nothing if schema-level timestamps are not set. * @return {Query} * @see Query docs https://mongoosejs.com/docs/queries.html * @see MongoDB docs https://www.mongodb.com/docs/manual/reference/command/update/#update-command-output @@ -3772,11 +3772,11 @@ Model.updateMany = function updateMany(conditions, doc, options) { * * @param {Object} filter * @param {Object|Array} update - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions) + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) * @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document - * @param {Object} [options.writeConcern=null] sets the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](/docs/guide.html#writeConcern) - * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set. + * @param {Object} [options.writeConcern=null] sets the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](https://mongoosejs.com/docs/guide.html#writeConcern) + * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set. * @return {Query} * @see Query docs https://mongoosejs.com/docs/queries.html * @see MongoDB docs https://www.mongodb.com/docs/manual/reference/command/update/#update-command-output @@ -3808,11 +3808,11 @@ Model.updateOne = function updateOne(conditions, doc, options) { * * @param {Object} filter * @param {Object} doc - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions) + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) * @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document - * @param {Object} [options.writeConcern=null] sets the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](/docs/guide.html#writeConcern) - * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Does nothing if schema-level timestamps are not set. + * @param {Object} [options.writeConcern=null] sets the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](https://mongoosejs.com/docs/guide.html#writeConcern) + * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Does nothing if schema-level timestamps are not set. * @return {Query} * @see Query docs https://mongoosejs.com/docs/queries.html * @see UpdateResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/UpdateResult.html @@ -3891,11 +3891,11 @@ function _update(model, op, conditions, doc, options) { * * #### More About Aggregations: * - * - [Mongoose `Aggregate`](/docs/api/aggregate.html) + * - [Mongoose `Aggregate`](https://mongoosejs.com/docs/api/aggregate.html) * - [An Introduction to Mongoose Aggregate](https://masteringjs.io/tutorials/mongoose/aggregate) * - [MongoDB Aggregation docs](https://www.mongodb.com/docs/manual/applications/aggregation/) * - * @see Aggregate #aggregate_Aggregate + * @see Aggregate https://mongoosejs.com/docs/api/aggregate.html#Aggregate() * @see MongoDB https://www.mongodb.com/docs/manual/applications/aggregation/ * @param {Array} [pipeline] aggregation pipeline as an array of objects * @param {Object} [options] aggregation options @@ -4086,9 +4086,9 @@ Model.validate = async function validate(obj, pathsToValidate, context) { * @param {Document|Array} docs Either a single document or array of documents to populate. * @param {Object|String} options Either the paths to populate or an object specifying all parameters * @param {string} [options.path=null] The path to populate. - * @param {string|PopulateOptions} [options.populate=null] Recursively populate paths in the populated documents. See [deep populate docs](/docs/populate.html#deep-populate). + * @param {string|PopulateOptions} [options.populate=null] Recursively populate paths in the populated documents. See [deep populate docs](https://mongoosejs.com/docs/populate.html#deep-populate). * @param {boolean} [options.retainNullValues=false] By default, Mongoose removes null and undefined values from populated arrays. Use this option to make `populate()` retain `null` and `undefined` array entries. - * @param {boolean} [options.getters=false] If true, Mongoose will call any getters defined on the `localField`. By default, Mongoose gets the raw value of `localField`. For example, you would need to set this option to `true` if you wanted to [add a `lowercase` getter to your `localField`](/docs/schematypes.html#schematype-options). + * @param {boolean} [options.getters=false] If true, Mongoose will call any getters defined on the `localField`. By default, Mongoose gets the raw value of `localField`. For example, you would need to set this option to `true` if you wanted to [add a `lowercase` getter to your `localField`](https://mongoosejs.com/docs/schematypes.html#schematype-options). * @param {boolean} [options.clone=false] When you do `BlogPost.find().populate('author')`, blog posts with the same author will share 1 copy of an `author` doc. Enable this option to make Mongoose clone populated docs before assigning them. * @param {Object|Function} [options.match=null] Add an additional filter to the populate query. Can be a filter object containing [MongoDB query syntax](https://www.mongodb.com/docs/manual/tutorial/query-documents/), or a function that returns a filter object. * @param {Boolean} [options.skipInvalidIds=false] By default, Mongoose throws a cast error if `localField` and `foreignField` schemas don't line up. If you enable this option, Mongoose will instead filter out any `localField` properties that cannot be casted to `foreignField`'s schema type. diff --git a/lib/options/SchemaNumberOptions.js b/lib/options/SchemaNumberOptions.js index bd91da01b19..126e4244bac 100644 --- a/lib/options/SchemaNumberOptions.js +++ b/lib/options/SchemaNumberOptions.js @@ -69,7 +69,7 @@ Object.defineProperty(SchemaNumberOptions.prototype, 'max', opts); Object.defineProperty(SchemaNumberOptions.prototype, 'enum', opts); /** - * Sets default [populate options](/docs/populate.html#query-conditions). + * Sets default [populate options](https://mongoosejs.com/docs/populate.html#query-conditions). * * #### Example: * diff --git a/lib/options/SchemaObjectIdOptions.js b/lib/options/SchemaObjectIdOptions.js index 37048e92c4d..81c7bce7fbf 100644 --- a/lib/options/SchemaObjectIdOptions.js +++ b/lib/options/SchemaObjectIdOptions.js @@ -32,7 +32,7 @@ const opts = require('./propertyOptions'); Object.defineProperty(SchemaObjectIdOptions.prototype, 'auto', opts); /** - * Sets default [populate options](/docs/populate.html#query-conditions). + * Sets default [populate options](https://mongoosejs.com/docs/populate.html#query-conditions). * * #### Example: * diff --git a/lib/options/SchemaStringOptions.js b/lib/options/SchemaStringOptions.js index 49836ef13d0..69fe174070b 100644 --- a/lib/options/SchemaStringOptions.js +++ b/lib/options/SchemaStringOptions.js @@ -120,7 +120,7 @@ Object.defineProperty(SchemaStringOptions.prototype, 'maxLength', opts); Object.defineProperty(SchemaStringOptions.prototype, 'maxlength', opts); /** - * Sets default [populate options](/docs/populate.html#query-conditions). + * Sets default [populate options](https://mongoosejs.com/docs/populate.html#query-conditions). * * @api public * @property populate diff --git a/lib/options/SchemaTypeOptions.js b/lib/options/SchemaTypeOptions.js index f2376431034..cfe3de3cd24 100644 --- a/lib/options/SchemaTypeOptions.js +++ b/lib/options/SchemaTypeOptions.js @@ -161,7 +161,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'index', opts); /** * 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). + * model is compiled. [The `unique` option is **not** a validator](https://mongoosejs.com/docs/validation.html#the-unique-option-is-not-a-validator). * * @api public * @property unique diff --git a/lib/options/VirtualOptions.js b/lib/options/VirtualOptions.js index 3db53b99d27..c17c5a405ff 100644 --- a/lib/options/VirtualOptions.js +++ b/lib/options/VirtualOptions.js @@ -146,7 +146,7 @@ Object.defineProperty(VirtualOptions.prototype, 'skip', opts); Object.defineProperty(VirtualOptions.prototype, 'limit', opts); /** - * The `limit` option for `populate()` has [some unfortunate edge cases](/docs/populate.html#query-conditions) + * The `limit` option for `populate()` has [some unfortunate edge cases](https://mongoosejs.com/docs/populate.html#query-conditions) * when working with multiple documents, like `.find().populate()`. The * `perDocumentLimit` option makes `populate()` execute a separate query * for each document returned from `find()` to ensure each document diff --git a/lib/query.js b/lib/query.js index 56ca0638554..3a84505b374 100644 --- a/lib/query.js +++ b/lib/query.js @@ -67,7 +67,7 @@ const queryOptionMethods = new Set([ /** * Query constructor used for building queries. You do not need * to instantiate a `Query` directly. Instead use Model functions like - * [`Model.find()`](/docs/api/model.html#model_Model-find). + * [`Model.find()`](https://mongoosejs.com/docs/api/model.html#Model.find()). * * #### Example: * @@ -812,7 +812,7 @@ Query.prototype.mod = function() { * * #### Note: * - * As of Mongoose 3.7, `$geoWithin` is always used for queries. To change this behavior, see [Query.use$geoWithin](#query_Query-use%2524geoWithin). + * As of Mongoose 3.7, `$geoWithin` is always used for queries. To change this behavior, see [Query.use$geoWithin](https://mongoosejs.com/docs/api/query.html#Query.prototype.use$geoWithin). * * #### Note: * @@ -999,7 +999,7 @@ Query.prototype.projection = function(arg) { /** * Specifies which document fields to include or exclude (also known as the query "projection") * - * When using string syntax, prefixing a path with `-` will flag that path as excluded. When a path does not have the `-` prefix, it is included. Lastly, if a path is prefixed with `+`, it forces inclusion of the path, which is useful for paths excluded at the [schema level](/docs/api/schematype.html#schematype_SchemaType-select). + * When using string syntax, prefixing a path with `-` will flag that path as excluded. When a path does not have the `-` prefix, it is included. Lastly, if a path is prefixed with `+`, it forces inclusion of the path, which is useful for paths excluded at the [schema level](https://mongoosejs.com/docs/api/schematype.html#SchemaType.prototype.select()). * * A projection _must_ be either inclusive or exclusive. In other words, you must * either list the fields to include (which excludes all others), or list the fields @@ -1040,7 +1040,7 @@ Query.prototype.projection = function(arg) { * @instance * @param {Object|String|String[]} arg * @return {Query} this - * @see SchemaType /docs/api/schematype.html + * @see SchemaType https://mongoosejs.com/docs/api/schematype.html * @api public */ @@ -1227,7 +1227,7 @@ Query.prototype.toString = function toString() { /** * Sets the [MongoDB session](https://www.mongodb.com/docs/manual/reference/server-sessions/) * associated with this query. Sessions are how you mark a query as part of a - * [transaction](/docs/transactions.html). + * [transaction](https://mongoosejs.com/docs/transactions.html). * * Calling `session(null)` removes the session from this query. * @@ -1240,8 +1240,8 @@ Query.prototype.toString = function toString() { * @memberOf Query * @instance * @param {ClientSession} [session] from `await conn.startSession()` - * @see Connection.prototype.startSession() /docs/api/connection.html#connection_Connection-startSession - * @see mongoose.startSession() /docs/api/mongoose.html#mongoose_Mongoose-startSession + * @see Connection.prototype.startSession() https://mongoosejs.com/docs/api/connection.html#Connection.prototype.startSession() + * @see mongoose.startSession() https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.startSession() * @return {Query} this * @api public */ @@ -1259,7 +1259,7 @@ Query.prototype.session = function session(v) { * * - `w`: Sets the specified number of `mongod` servers, or tag set of `mongod` servers, that must acknowledge this write before this write is considered successful. * - `j`: Boolean, set to `true` to request acknowledgement that this operation has been persisted to MongoDB's on-disk journal. - * - `wtimeout`: If [`w > 1`](#query_Query-w), the maximum amount of time to wait for this write to propagate through the replica set before this operation fails. The default is `0`, which means no timeout. + * - `wtimeout`: If [`w > 1`](https://mongoosejs.com/docs/api/query.html#Query.prototype.w()), the maximum amount of time to wait for this write to propagate through the replica set before this operation fails. The default is `0`, which means no timeout. * * This option is only valid for operations that write to the database: * @@ -1271,7 +1271,7 @@ Query.prototype.session = function session(v) { * - `updateOne()` * - `updateMany()` * - * Defaults to the schema's [`writeConcern` option](/docs/guide.html#writeConcern) + * Defaults to the schema's [`writeConcern` option](https://mongoosejs.com/docs/guide.html#writeConcern) * * #### Example: * @@ -1312,7 +1312,7 @@ Query.prototype.writeConcern = function writeConcern(val) { * - `updateOne()` * - `updateMany()` * - * Defaults to the schema's [`writeConcern.w` option](/docs/guide.html#writeConcern) + * Defaults to the schema's [`writeConcern.w` option](https://mongoosejs.com/docs/guide.html#writeConcern) * * #### Example: * @@ -1356,7 +1356,7 @@ Query.prototype.w = function w(val) { * - `updateOne()` * - `updateMany()` * - * Defaults to the schema's [`writeConcern.j` option](/docs/guide.html#writeConcern) + * Defaults to the schema's [`writeConcern.j` option](https://mongoosejs.com/docs/guide.html#writeConcern) * * #### Example: * @@ -1384,7 +1384,7 @@ Query.prototype.j = function j(val) { }; /** - * If [`w > 1`](#query_Query-w), the maximum amount of time to + * If [`w > 1`](https://mongoosejs.com/docs/api/query.html#Query.prototype.w()), the maximum amount of time to * wait for this write to propagate through the replica set before this * operation fails. The default is `0`, which means no timeout. * @@ -1398,7 +1398,7 @@ Query.prototype.j = function j(val) { * - `updateOne()` * - `updateMany()` * - * Defaults to the schema's [`writeConcern.wtimeout` option](/docs/guide.html#writeConcern) + * Defaults to the schema's [`writeConcern.wtimeout` option](https://mongoosejs.com/docs/guide.html#writeConcern) * * #### Example: * @@ -1526,9 +1526,9 @@ Query.prototype.getOptions = function() { * * The following options are only for `find()`, `findOne()`, `findById()`, `findOneAndUpdate()`, and `findByIdAndUpdate()`: * - * - [lean](#query_Query-lean) - * - [populate](/docs/populate.html) - * - [projection](#query_Query-projection) + * - [lean](https://mongoosejs.com/docs/api/query.html#Query.prototype.lean()) + * - [populate](https://mongoosejs.com/docs/populate.html) + * - [projection](https://mongoosejs.com/docs/api/query.html#Query.prototype.projection()) * - sanitizeProjection * * The following options are only for all operations **except** `updateOne()`, `updateMany()`, `deleteOne()`, and `deleteMany()`: @@ -1541,7 +1541,7 @@ Query.prototype.getOptions = function() { * * The following options are for all operations: * - * - [strict](/docs/guide.html#strict) + * - [strict](https://mongoosejs.com/docs/guide.html#strict) * - [collation](https://www.mongodb.com/docs/manual/reference/collation/) * - [session](https://www.mongodb.com/docs/manual/reference/server-sessions/) * - [explain](https://www.mongodb.com/docs/manual/reference/method/cursor.explain/) @@ -1967,7 +1967,7 @@ Query.prototype._optionsForExec = function(model) { * Sets the lean option. * * Documents returned from queries with the `lean` option enabled are plain - * javascript objects, not [Mongoose Documents](/docs/api/document.html). They have no + * javascript objects, not [Mongoose Documents](https://mongoosejs.com/docs/api/document.html). They have no * `save` method, getters/setters, virtuals, or other Mongoose features. * * #### Example: @@ -1979,9 +1979,9 @@ Query.prototype._optionsForExec = function(model) { * const docs = await Model.find().lean(); * docs[0] instanceof mongoose.Document; // false * - * [Lean is great for high-performance, read-only cases](/docs/tutorials/lean.html), + * [Lean is great for high-performance, read-only cases](https://mongoosejs.com/docs/tutorials/lean.html), * especially when combined - * with [cursors](/docs/queries.html#streaming). + * with [cursors](https://mongoosejs.com/docs/queries.html#streaming). * * If you need virtuals, getters/setters, or defaults with `lean()`, you need * to use a plugin. See: @@ -2129,11 +2129,11 @@ Query.prototype._unsetCastError = function _unsetCastError() { * Getter/setter around the current mongoose-specific options for this query * Below are the current Mongoose-specific options. * - * - `populate`: an array representing what paths will be populated. Should have one entry for each call to [`Query.prototype.populate()`](#query_Query-populate) - * - `lean`: if truthy, Mongoose will not [hydrate](/docs/api/model.html#model_Model-hydrate) any documents that are returned from this query. See [`Query.prototype.lean()`](#query_Query-lean) for more information. - * - `strict`: controls how Mongoose handles keys that aren't in the schema for updates. This option is `true` by default, which means Mongoose will silently strip any paths in the update that aren't in the schema. See the [`strict` mode docs](/docs/guide.html#strict) for more information. - * - `strictQuery`: controls how Mongoose handles keys that aren't in the schema for the query `filter`. This option is `false` by default, which means Mongoose will allow `Model.find({ foo: 'bar' })` even if `foo` is not in the schema. See the [`strictQuery` docs](/docs/guide.html#strictQuery) for more information. - * - `nearSphere`: use `$nearSphere` instead of `near()`. See the [`Query.prototype.nearSphere()` docs](#query_Query-nearSphere) + * - `populate`: an array representing what paths will be populated. Should have one entry for each call to [`Query.prototype.populate()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.populate()) + * - `lean`: if truthy, Mongoose will not [hydrate](https://mongoosejs.com/docs/api/model.html#Model.hydrate()) any documents that are returned from this query. See [`Query.prototype.lean()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.lean()) for more information. + * - `strict`: controls how Mongoose handles keys that aren't in the schema for updates. This option is `true` by default, which means Mongoose will silently strip any paths in the update that aren't in the schema. See the [`strict` mode docs](https://mongoosejs.com/docs/guide.html#strict) for more information. + * - `strictQuery`: controls how Mongoose handles keys that aren't in the schema for the query `filter`. This option is `false` by default, which means Mongoose will allow `Model.find({ foo: 'bar' })` even if `foo` is not in the schema. See the [`strictQuery` docs](https://mongoosejs.com/docs/guide.html#strictQuery) for more information. + * - `nearSphere`: use `$nearSphere` instead of `near()`. See the [`Query.prototype.nearSphere()` docs](https://mongoosejs.com/docs/api/query.html#Query.prototype.nearSphere()) * * Mongoose maintains a separate object for internal options because * Mongoose sends `Query.prototype.options` to the MongoDB server, and the @@ -2268,7 +2268,7 @@ Query.prototype._find = async function _find() { * Find all documents that match `selector`. The result will be an array of documents. * * If there are too many documents in the result to fit in memory, use - * [`Query.prototype.cursor()`](#query_Query-cursor) + * [`Query.prototype.cursor()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.cursor()) * * #### Example: * @@ -2509,10 +2509,10 @@ Query.prototype._findOne = async function _findOne() { * * @param {Object} [filter] mongodb selector * @param {Object} [projection] optional fields to return - * @param {Object} [options] see [`setOptions()`](#query_Query-setOptions) + * @param {Object} [options] see [`setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) * @return {Query} this * @see findOne https://www.mongodb.com/docs/manual/reference/method/db.collection.findOne/ - * @see Query.select #query_Query-select + * @see Query.select https://mongoosejs.com/docs/api/query.html#Query.prototype.select() * @api public */ @@ -2626,8 +2626,8 @@ Query.prototype._estimatedDocumentCount = async function _estimatedDocumentCount * Specifies this query as a `count` query. * * This method is deprecated. If you want to count the number of documents in - * a collection, e.g. `count({})`, use the [`estimatedDocumentCount()` function](#query_Query-estimatedDocumentCount) - * instead. Otherwise, use the [`countDocuments()`](#query_Query-countDocuments) function instead. + * a collection, e.g. `count({})`, use the [`estimatedDocumentCount()` function](https://mongoosejs.com/docs/api/query.html#Query.prototype.estimatedDocumentCount()) + * instead. Otherwise, use the [`countDocuments()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.countDocuments()) function instead. * * This function triggers the following middleware. * @@ -2899,7 +2899,7 @@ Query.prototype.sort = function(arg) { * res.deletedCount; * * @param {Object|Query} [filter] mongodb selector - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](#query_Query-setOptions) + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) * @return {Query} this * @see DeleteResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/DeleteResult.html * @see deleteOne https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#deleteOne @@ -2975,7 +2975,7 @@ Query.prototype._deleteOne = async function _deleteOne() { * res.deletedCount; * * @param {Object|Query} [filter] mongodb selector - * @param {Object} [options] optional see [`Query.prototype.setOptions()`](#query_Query-setOptions) + * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions()) * @return {Query} this * @see DeleteResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/DeleteResult.html * @see deleteMany https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#deleteMany @@ -3106,7 +3106,7 @@ function prepareDiscriminatorCriteria(query) { * - `fields`: {Object|String} - Field selection. Equivalent to `.select(fields).findOneAndUpdate()` * - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update * - `maxTimeMS`: puts a time limit on the query - requires mongodb >= 2.6.0 - * - `runValidators`: if true, runs [update validators](/docs/validation.html#update-validators) on this command. Update validators validate the update operation against the model's schema. + * - `runValidators`: if true, runs [update validators](https://mongoosejs.com/docs/validation.html#update-validators) on this command. Update validators validate the update operation against the model's schema. * - `setDefaultsOnInsert`: `true` by default. If `setDefaultsOnInsert` and `upsert` are true, mongoose will apply the [defaults](https://mongoosejs.com/docs/defaults.html) specified in the model's schema if a new document is created. * - `rawResult`: if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html) * @@ -3125,15 +3125,15 @@ function prepareDiscriminatorCriteria(query) { * @param {Object} [options] * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html) * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) - * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html). + * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html). * @param {Boolean} [options.multipleCastError] by default, mongoose only returns the first error that occurred in casting the query. Turn on this option to aggregate all the cast errors. * @param {Boolean} [options.new=false] By default, `findOneAndUpdate()` returns the document as it was **before** `update` was applied. If you set `new: true`, `findOneAndUpdate()` will instead give you the object after `update` was applied. - * @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](#query_Query-lean) and [the Mongoose lean tutorial](/docs/tutorials/lean.html). - * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html). + * @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.lean()) and [the Mongoose lean tutorial](https://mongoosejs.com/docs/tutorials/lean.html). + * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html). * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) - * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set. + * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set. * @param {Boolean} [options.returnOriginal=null] An alias for the `new` option. `returnOriginal: false` is equivalent to `new: true`. - * @see Tutorial /docs/tutorials/findoneandupdate.html + * @see Tutorial https://mongoosejs.com/docs/tutorials/findoneandupdate.html * @see findAndModify command https://www.mongodb.com/docs/manual/reference/command/findAndModify/ * @see ModifyResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html * @see findOneAndUpdate https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#findOneAndUpdate @@ -3309,7 +3309,7 @@ Query.prototype._findOneAndUpdate = async function _findOneAndUpdate() { * @param {Object} [conditions] * @param {Object} [options] * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html) - * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html). + * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html). * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) * @return {Query} this * @see findAndModify command https://www.mongodb.com/docs/manual/reference/command/findAndModify/ @@ -3369,7 +3369,7 @@ Query.prototype.findOneAndRemove = function(conditions, options) { * @param {Object} [conditions] * @param {Object} [options] * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html) - * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html). + * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html). * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) * @return {Query} this * @see findAndModify command https://www.mongodb.com/docs/manual/reference/command/findAndModify/ @@ -3474,13 +3474,13 @@ Query.prototype._findOneAndDelete = async function _findOneAndDelete() { * @param {Object} [replacement] * @param {Object} [options] * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html) - * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html). + * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html). * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) * @param {Boolean} [options.new=false] By default, `findOneAndUpdate()` returns the document as it was **before** `update` was applied. If you set `new: true`, `findOneAndUpdate()` will instead give you the object after `update` was applied. - * @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](#query_Query-lean) and [the Mongoose lean tutorial](/docs/tutorials/lean.html). - * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html). + * @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.lean()) and [the Mongoose lean tutorial](https://mongoosejs.com/docs/tutorials/lean.html). + * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html). * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) - * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set. + * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set. * @param {Boolean} [options.returnOriginal=null] An alias for the `new` option. `returnOriginal: false` is equivalent to `new: true`. * @return {Query} this * @api public @@ -3858,7 +3858,7 @@ Query.prototype.validate = async function validate(castedDoc, options, isOverwri /** * Execute an updateMany query * - * @see Model.update #model_Model-update + * @see Model.update https://mongoosejs.com/docs/api/model.html#Model.update() * @method _updateMany * @memberOf Query * @instance @@ -3871,7 +3871,7 @@ Query.prototype._updateMany = async function _updateMany() { /** * Execute an updateOne query * - * @see Model.update #model_Model-update + * @see Model.update https://mongoosejs.com/docs/api/model.html#Model.update() * @method _updateOne * @memberOf Query * @instance @@ -3884,7 +3884,7 @@ Query.prototype._updateOne = async function _updateOne() { /** * Execute a replaceOne query * - * @see Model.replaceOne #model_Model-replaceOne + * @see Model.replaceOne https://mongoosejs.com/docs/api/model.html#Model.replaceOne() * @method _replaceOne * @memberOf Query * @instance @@ -3917,11 +3917,11 @@ Query.prototype._replaceOne = async function _replaceOne() { * @param {Boolean} [options.multipleCastError] by default, mongoose only returns the first error that occurred in casting the query. Turn on this option to aggregate all the cast errors. * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) * @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document - * @param {Object} [options.writeConcern=null] sets the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](/docs/guide.html#writeConcern) - * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Does nothing if schema-level timestamps are not set. + * @param {Object} [options.writeConcern=null] sets the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](https://mongoosejs.com/docs/guide.html#writeConcern) + * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Does nothing if schema-level timestamps are not set. * @param {Function} [callback] params are (error, writeOpResult) * @return {Query} this - * @see Model.update #model_Model-update + * @see Model.update https://mongoosejs.com/docs/api/model.html#Model.update() * @see Query docs https://mongoosejs.com/docs/queries.html * @see update https://www.mongodb.com/docs/manual/reference/method/db.collection.update/ * @see UpdateResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/UpdateResult.html @@ -3985,11 +3985,11 @@ Query.prototype.updateMany = function(conditions, doc, options, callback) { * @param {Boolean} [options.multipleCastError] by default, mongoose only returns the first error that occurred in casting the query. Turn on this option to aggregate all the cast errors. * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) * @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document - * @param {Object} [options.writeConcern=null] sets the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](/docs/guide.html#writeConcern) - * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set. + * @param {Object} [options.writeConcern=null] sets the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](https://mongoosejs.com/docs/guide.html#writeConcern) + * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set. * @param {Function} [callback] params are (error, writeOpResult) * @return {Query} this - * @see Model.update #model_Model-update + * @see Model.update https://mongoosejs.com/docs/api/model.html#Model.update() * @see Query docs https://mongoosejs.com/docs/queries.html * @see update https://www.mongodb.com/docs/manual/reference/method/db.collection.update/ * @see UpdateResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/UpdateResult.html @@ -4051,11 +4051,11 @@ Query.prototype.updateOne = function(conditions, doc, options, callback) { * @param {Boolean} [options.multipleCastError] by default, mongoose only returns the first error that occurred in casting the query. Turn on this option to aggregate all the cast errors. * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict) * @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document - * @param {Object} [options.writeConcern=null] sets the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](/docs/guide.html#writeConcern) - * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Does nothing if schema-level timestamps are not set. + * @param {Object} [options.writeConcern=null] sets the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](https://mongoosejs.com/docs/guide.html#writeConcern) + * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Does nothing if schema-level timestamps are not set. * @param {Function} [callback] params are (error, writeOpResult) * @return {Query} this - * @see Model.update #model_Model-update + * @see Model.update https://mongoosejs.com/docs/api/model.html#Model.update() * @see Query docs https://mongoosejs.com/docs/queries.html * @see update https://www.mongodb.com/docs/manual/reference/method/db.collection.update/ * @see UpdateResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/UpdateResult.html @@ -4500,7 +4500,7 @@ Query.prototype[Symbol.toStringTag] = function toString() { }; /** - * Add pre [middleware](/docs/middleware.html) to this query instance. Doesn't affect + * Add pre [middleware](https://mongoosejs.com/docs/middleware.html) to this query instance. Doesn't affect * other queries. * * #### Example: @@ -4526,7 +4526,7 @@ Query.prototype.pre = function(fn) { }; /** - * Add post [middleware](/docs/middleware.html) to this query instance. Doesn't affect + * Add post [middleware](https://mongoosejs.com/docs/middleware.html) to this query instance. Doesn't affect * other queries. * * #### Example: @@ -4645,14 +4645,14 @@ Query.prototype._castUpdate = function _castUpdate(obj, overwrite) { * @param {Object} [options] Options for the population query (sort, etc) * @param {String} [options.path=null] The path to populate. * @param {boolean} [options.retainNullValues=false] by default, Mongoose removes null and undefined values from populated arrays. Use this option to make `populate()` retain `null` and `undefined` array entries. - * @param {boolean} [options.getters=false] if true, Mongoose will call any getters defined on the `localField`. By default, Mongoose gets the raw value of `localField`. For example, you would need to set this option to `true` if you wanted to [add a `lowercase` getter to your `localField`](/docs/schematypes.html#schematype-options). + * @param {boolean} [options.getters=false] if true, Mongoose will call any getters defined on the `localField`. By default, Mongoose gets the raw value of `localField`. For example, you would need to set this option to `true` if you wanted to [add a `lowercase` getter to your `localField`](https://mongoosejs.com/docs/schematypes.html#schematype-options). * @param {boolean} [options.clone=false] When you do `BlogPost.find().populate('author')`, blog posts with the same author will share 1 copy of an `author` doc. Enable this option to make Mongoose clone populated docs before assigning them. * @param {Object|Function} [options.match=null] Add an additional filter to the populate query. Can be a filter object containing [MongoDB query syntax](https://www.mongodb.com/docs/manual/tutorial/query-documents/), or a function that returns a filter object. * @param {Function} [options.transform=null] Function that Mongoose will call on every populated document that allows you to transform the populated document. * @param {Object} [options.options=null] Additional options like `limit` and `lean`. - * @see population /docs/populate.html - * @see Query#select #query_Query-select - * @see Model.populate #model_Model-populate + * @see population https://mongoosejs.com/docs/populate.html + * @see Query#select https://mongoosejs.com/docs/api/query.html#Query.prototype.select() + * @see Model.populate https://mongoosejs.com/docs/api/model.html#Model.populate() * @return {Query} this * @api public */ @@ -4920,7 +4920,7 @@ Query.prototype._applyPaths = function applyPaths() { * * @return {QueryCursor} * @param {Object} [options] - * @see QueryCursor /docs/api/querycursor.html + * @see QueryCursor https://mongoosejs.com/docs/api/querycursor.html * @api public */ @@ -5171,7 +5171,7 @@ Query.prototype.near = function() { * query.where('loc').near({ center: [10, 10], spherical: true }); * * @deprecated - * @see near() #query_Query-near + * @see near() https://mongoosejs.com/docs/api/query.html#Query.prototype.near() * @see $near https://www.mongodb.com/docs/manual/reference/operator/near/ * @see $nearSphere https://www.mongodb.com/docs/manual/reference/operator/nearSphere/ * @see $maxDistance https://www.mongodb.com/docs/manual/reference/operator/maxDistance/ @@ -5226,7 +5226,7 @@ if (Symbol.asyncIterator != null) { * @memberOf Query * @instance * @param {String|Array} [path] - * @param {Array|Object} [coordinatePairs...] + * @param {...Array|Object} [coordinatePairs] * @return {Query} this * @see $polygon https://www.mongodb.com/docs/manual/reference/operator/polygon/ * @see MongoDB Geospatial Indexing https://www.mongodb.com/docs/manual/core/geospatial-indexes/ @@ -5248,7 +5248,7 @@ if (Symbol.asyncIterator != null) { * @memberOf Query * @instance * @see $box https://www.mongodb.com/docs/manual/reference/operator/box/ - * @see within() Query#within #query_Query-within + * @see within() Query#within https://mongoosejs.com/docs/api/query.html#Query.prototype.within() * @see MongoDB Geospatial Indexing https://www.mongodb.com/docs/manual/core/geospatial-indexes/ * @param {Object|Array} val1 Lower Left Coordinates OR a object of lower-left(ll) and upper-right(ur) Coordinates * @param {Array} [val2] Upper Right Coordinates @@ -5305,9 +5305,9 @@ Query.prototype.box = function(ll, ur) { */ /** - * _DEPRECATED_ Alias for [circle](#query_Query-circle) + * _DEPRECATED_ Alias for [circle](https://mongoosejs.com/docs/api/query.html#Query.prototype.circle()) * - * **Deprecated.** Use [circle](#query_Query-circle) instead. + * **Deprecated.** Use [circle](https://mongoosejs.com/docs/api/query.html#Query.prototype.circle()) instead. * * @deprecated * @method center @@ -5321,7 +5321,7 @@ Query.prototype.center = Query.base.circle; /** * _DEPRECATED_ Specifies a `$centerSphere` condition * - * **Deprecated.** Use [circle](#query_Query-circle) instead. + * **Deprecated.** Use [circle](https://mongoosejs.com/docs/api/query.html#Query.prototype.circle()) instead. * * #### Example: * diff --git a/lib/schema.js b/lib/schema.js index 8a7a7150e67..7b5ef0ece89 100644 --- a/lib/schema.js +++ b/lib/schema.js @@ -51,33 +51,33 @@ let id = 0; * * #### Options: * - * - [autoIndex](/docs/guide.html#autoIndex): bool - defaults to null (which means use the connection's autoIndex option) - * - [autoCreate](/docs/guide.html#autoCreate): bool - defaults to null (which means use the connection's autoCreate option) - * - [bufferCommands](/docs/guide.html#bufferCommands): bool - defaults to true - * - [bufferTimeoutMS](/docs/guide.html#bufferTimeoutMS): number - defaults to 10000 (10 seconds). If `bufferCommands` is enabled, the amount of time Mongoose will wait for connectivity to be restablished before erroring out. - * - [capped](/docs/guide.html#capped): bool | number | object - defaults to false - * - [collection](/docs/guide.html#collection): string - no default - * - [discriminatorKey](/docs/guide.html#discriminatorKey): string - defaults to `__t` - * - [id](/docs/guide.html#id): bool - defaults to true - * - [_id](/docs/guide.html#_id): bool - defaults to true - * - [minimize](/docs/guide.html#minimize): bool - controls [document#toObject](#document_Document-toObject) behavior when called manually - defaults to true - * - [read](/docs/guide.html#read): string - * - [writeConcern](/docs/guide.html#writeConcern): object - defaults to null, use to override [the MongoDB server's default write concern settings](https://www.mongodb.com/docs/manual/reference/write-concern/) - * - [shardKey](/docs/guide.html#shardKey): object - defaults to `null` - * - [strict](/docs/guide.html#strict): bool - defaults to true - * - [strictQuery](/docs/guide.html#strictQuery): bool - defaults to false - * - [toJSON](/docs/guide.html#toJSON) - object - no default - * - [toObject](/docs/guide.html#toObject) - object - no default - * - [typeKey](/docs/guide.html#typeKey) - string - defaults to 'type' - * - [validateBeforeSave](/docs/guide.html#validateBeforeSave) - bool - defaults to `true` - * - [versionKey](/docs/guide.html#versionKey): string or object - defaults to "__v" - * - [optimisticConcurrency](/docs/guide.html#optimisticConcurrency): bool - defaults to false. Set to true to enable [optimistic concurrency](https://thecodebarbarian.com/whats-new-in-mongoose-5-10-optimistic-concurrency.html). - * - [collation](/docs/guide.html#collation): object - defaults to null (which means use no collation) - * - [timeseries](/docs/guide.html#timeseries): object - defaults to null (which means this schema's collection won't be a timeseries collection) - * - [selectPopulatedPaths](/docs/guide.html#selectPopulatedPaths): boolean - defaults to `true` - * - [skipVersioning](/docs/guide.html#skipVersioning): object - paths to exclude from versioning - * - [timestamps](/docs/guide.html#timestamps): object or boolean - defaults to `false`. If true, Mongoose adds `createdAt` and `updatedAt` properties to your schema and manages those properties for you. - * - [pluginTags](/docs/guide.html#pluginTags): array of strings - defaults to `undefined`. If set and plugin called with `tags` option, will only apply that plugin to schemas with a matching tag. + * - [autoIndex](https://mongoosejs.com/docs/guide.html#autoIndex): bool - defaults to null (which means use the connection's autoIndex option) + * - [autoCreate](https://mongoosejs.com/docs/guide.html#autoCreate): bool - defaults to null (which means use the connection's autoCreate option) + * - [bufferCommands](https://mongoosejs.com/docs/guide.html#bufferCommands): bool - defaults to true + * - [bufferTimeoutMS](https://mongoosejs.com/docs/guide.html#bufferTimeoutMS): number - defaults to 10000 (10 seconds). If `bufferCommands` is enabled, the amount of time Mongoose will wait for connectivity to be restablished before erroring out. + * - [capped](https://mongoosejs.com/docs/guide.html#capped): bool | number | object - defaults to false + * - [collection](https://mongoosejs.com/docs/guide.html#collection): string - no default + * - [discriminatorKey](https://mongoosejs.com/docs/guide.html#discriminatorKey): string - defaults to `__t` + * - [id](https://mongoosejs.com/docs/guide.html#id): bool - defaults to true + * - [_id](https://mongoosejs.com/docs/guide.html#_id): bool - defaults to true + * - [minimize](https://mongoosejs.com/docs/guide.html#minimize): bool - controls [document#toObject](https://mongoosejs.com/docs/api/document.html#Document.prototype.toObject()) behavior when called manually - defaults to true + * - [read](https://mongoosejs.com/docs/guide.html#read): string + * - [writeConcern](https://mongoosejs.com/docs/guide.html#writeConcern): object - defaults to null, use to override [the MongoDB server's default write concern settings](https://www.mongodb.com/docs/manual/reference/write-concern/) + * - [shardKey](https://mongoosejs.com/docs/guide.html#shardKey): object - defaults to `null` + * - [strict](https://mongoosejs.com/docs/guide.html#strict): bool - defaults to true + * - [strictQuery](https://mongoosejs.com/docs/guide.html#strictQuery): bool - defaults to false + * - [toJSON](https://mongoosejs.com/docs/guide.html#toJSON) - object - no default + * - [toObject](https://mongoosejs.com/docs/guide.html#toObject) - object - no default + * - [typeKey](https://mongoosejs.com/docs/guide.html#typeKey) - string - defaults to 'type' + * - [validateBeforeSave](https://mongoosejs.com/docs/guide.html#validateBeforeSave) - bool - defaults to `true` + * - [versionKey](https://mongoosejs.com/docs/guide.html#versionKey): string or object - defaults to "__v" + * - [optimisticConcurrency](https://mongoosejs.com/docs/guide.html#optimisticConcurrency): bool - defaults to false. Set to true to enable [optimistic concurrency](https://thecodebarbarian.com/whats-new-in-mongoose-5-10-optimistic-concurrency.html). + * - [collation](https://mongoosejs.com/docs/guide.html#collation): object - defaults to null (which means use no collation) + * - [timeseries](https://mongoosejs.com/docs/guide.html#timeseries): object - defaults to null (which means this schema's collection won't be a timeseries collection) + * - [selectPopulatedPaths](https://mongoosejs.com/docs/guide.html#selectPopulatedPaths): boolean - defaults to `true` + * - [skipVersioning](https://mongoosejs.com/docs/guide.html#skipVersioning): object - paths to exclude from versioning + * - [timestamps](https://mongoosejs.com/docs/guide.html#timestamps): object or boolean - defaults to `false`. If true, Mongoose adds `createdAt` and `updatedAt` properties to your schema and manages those properties for you. + * - [pluginTags](https://mongoosejs.com/docs/guide.html#pluginTags): array of strings - defaults to `undefined`. If set and plugin called with `tags` option, will only apply that plugin to schemas with a matching tag. * * #### Options for Nested Schemas: * @@ -1862,7 +1862,7 @@ Schema.prototype.post = function(name) { * @param {Function} plugin The Plugin's callback * @param {Object} [opts] Options to pass to the plugin * @param {Boolean} [opts.deduplicate=false] If true, ignore duplicate plugins (same `fn` argument using `===`) - * @see plugins /docs/plugins.html + * @see plugins https://mongoosejs.com/docs/plugins.html * @api public */ @@ -1913,7 +1913,7 @@ Schema.prototype.plugin = function(fn, opts) { * fizz.purr(); * fizz.scratch(); * - * NOTE: `Schema.method()` adds instance methods to the `Schema.methods` object. You can also add instance methods directly to the `Schema.methods` object as seen in the [guide](/docs/guide.html#methods) + * NOTE: `Schema.method()` adds instance methods to the `Schema.methods` object. You can also add instance methods directly to the `Schema.methods` object as seen in the [guide](https://mongoosejs.com/docs/guide.html#methods) * * @param {String|Object} name The Method Name for a single function, or a Object of "string-function" pairs. * @param {Function} [fn] The Function in a single-function definition. @@ -1963,7 +1963,7 @@ Schema.prototype.method = function(name, fn, options) { * @param {String|Object} name The Method Name for a single function, or a Object of "string-function" pairs. * @param {Function} [fn] The Function in a single-function definition. * @api public - * @see Statics /docs/guide.html#statics + * @see Statics https://mongoosejs.com/docs/guide.html#statics */ Schema.prototype.static = function(name, fn) { @@ -2015,7 +2015,7 @@ Schema.prototype.index = function(fields, options) { * @param {String} key The name of the option to set the value to * @param {Object} [value] The value to set the option to, if not passed, the option will be reset to default * @param {Array} [tags] tags to add to read preference if key === 'read' - * @see Schema #schema_Schema + * @see Schema https://mongoosejs.com/docs/api/schema.html#Schema() * @api public */ @@ -2115,7 +2115,7 @@ Object.defineProperty(Schema, 'indexTypes', { * // [ { registeredAt: 1 }, { background: true } ] ] * userSchema.indexes(); * - * [Plugins](/docs/plugins.html) can use the return value of this function to modify a schema's indexes. + * [Plugins](https://mongoosejs.com/docs/plugins.html) can use the return value of this function to modify a schema's indexes. * For example, the below plugin makes every index unique by default. * * function myPlugin(schema) { @@ -2139,12 +2139,12 @@ Schema.prototype.indexes = function() { * * @param {String} name The name of the Virtual * @param {Object} [options] - * @param {String|Model} [options.ref] model name or model instance. Marks this as a [populate virtual](/docs/populate.html#populate-virtuals). - * @param {String|Function} [options.localField] Required for populate virtuals. See [populate virtual docs](/docs/populate.html#populate-virtuals) for more information. - * @param {String|Function} [options.foreignField] Required for populate virtuals. See [populate virtual docs](/docs/populate.html#populate-virtuals) for more information. + * @param {String|Model} [options.ref] model name or model instance. Marks this as a [populate virtual](https://mongoosejs.com/docs/populate.html#populate-virtuals). + * @param {String|Function} [options.localField] Required for populate virtuals. See [populate virtual docs](https://mongoosejs.com/docs/populate.html#populate-virtuals) for more information. + * @param {String|Function} [options.foreignField] Required for populate virtuals. See [populate virtual docs](https://mongoosejs.com/docs/populate.html#populate-virtuals) for more information. * @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()`. - * @param {Function|null} [options.get=null] Adds a [getter](/docs/tutorials/getters-setters.html) to this virtual to transform the populated doc. + * @param {Function|null} [options.get=null] Adds a [getter](https://mongoosejs.com/docs/tutorials/getters-setters.html) to this virtual to transform the populated doc. * @return {VirtualType} */ @@ -2370,9 +2370,9 @@ Schema.prototype.removeVirtual = function(path) { /** * Loads an ES6 class into a schema. Maps [setters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set) + [getters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get), [static methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static), * and [instance methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes#Class_body_and_method_definitions) - * to schema [virtuals](/docs/guide.html#virtuals), - * [statics](/docs/guide.html#statics), and - * [methods](/docs/guide.html#methods). + * to schema [virtuals](https://mongoosejs.com/docs/guide.html#virtuals), + * [statics](https://mongoosejs.com/docs/guide.html#statics), and + * [methods](https://mongoosejs.com/docs/guide.html#methods). * * #### Example: * @@ -2657,14 +2657,14 @@ module.exports = exports = Schema; * * #### Types: * - * - [String](/docs/schematypes.html#strings) - * - [Number](/docs/schematypes.html#numbers) - * - [Boolean](/docs/schematypes.html#booleans) | Bool - * - [Array](/docs/schematypes.html#arrays) - * - [Buffer](/docs/schematypes.html#buffers) - * - [Date](/docs/schematypes.html#dates) - * - [ObjectId](/docs/schematypes.html#objectids) | Oid - * - [Mixed](/docs/schematypes.html#mixed) + * - [String](https://mongoosejs.com/docs/schematypes.html#strings) + * - [Number](https://mongoosejs.com/docs/schematypes.html#numbers) + * - [Boolean](https://mongoosejs.com/docs/schematypes.html#booleans) | Bool + * - [Array](https://mongoosejs.com/docs/schematypes.html#arrays) + * - [Buffer](https://mongoosejs.com/docs/schematypes.html#buffers) + * - [Date](https://mongoosejs.com/docs/schematypes.html#dates) + * - [ObjectId](https://mongoosejs.com/docs/schematypes.html#objectids) | Oid + * - [Mixed](https://mongoosejs.com/docs/schematypes.html#mixed) * * Using this exposed access to the `Mixed` SchemaType, we can use them in our schema. * diff --git a/lib/schema/SubdocumentPath.js b/lib/schema/SubdocumentPath.js index eb504181026..e66a1529539 100644 --- a/lib/schema/SubdocumentPath.js +++ b/lib/schema/SubdocumentPath.js @@ -296,7 +296,7 @@ SubdocumentPath.prototype.doValidateSync = function(value, scope, options) { * @param {String} [options.value] the string stored in the `discriminatorKey` property. If not specified, Mongoose uses the `name` parameter. * @param {Boolean} [options.clone=true] By default, `discriminator()` clones the given `schema`. Set to `false` to skip cloning. * @return {Function} the constructor Mongoose will use for creating instances of this discriminator model - * @see discriminators /docs/discriminators.html + * @see discriminators https://mongoosejs.com/docs/discriminators.html * @api public */ diff --git a/lib/schema/date.js b/lib/schema/date.js index f91343954e8..746f39df8b4 100644 --- a/lib/schema/date.js +++ b/lib/schema/date.js @@ -234,7 +234,7 @@ SchemaDate.prototype.checkRequired = function(value, doc) { * @param {Date} value minimum date * @param {String} [message] optional custom error message * @return {SchemaType} this - * @see Customized Error Messages #error_messages_MongooseError-messages + * @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages * @api public */ @@ -296,7 +296,7 @@ SchemaDate.prototype.min = function(value, message) { * @param {Date} maximum date * @param {String} [message] optional custom error message * @return {SchemaType} this - * @see Customized Error Messages #error_messages_MongooseError-messages + * @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages * @api public */ diff --git a/lib/schema/documentarray.js b/lib/schema/documentarray.js index 8e68240270c..e8a2ba15fb2 100644 --- a/lib/schema/documentarray.js +++ b/lib/schema/documentarray.js @@ -184,7 +184,7 @@ function _createConstructor(schema, options, baseClass) { * @param {Object|string} [options] If string, same as `options.value`. * @param {String} [options.value] the string stored in the `discriminatorKey` property. If not specified, Mongoose uses the `name` parameter. * @param {Boolean} [options.clone=true] By default, `discriminator()` clones the given `schema`. Set to `false` to skip cloning. - * @see discriminators /docs/discriminators.html + * @see discriminators https://mongoosejs.com/docs/discriminators.html * @return {Function} the constructor Mongoose will use for creating instances of this discriminator model * @api public */ diff --git a/lib/schema/number.js b/lib/schema/number.js index 2396c420630..48d3ff7ffda 100644 --- a/lib/schema/number.js +++ b/lib/schema/number.js @@ -204,7 +204,7 @@ SchemaNumber.prototype.checkRequired = function checkRequired(value, doc) { * @param {Number} value minimum number * @param {String} [message] optional custom error message * @return {SchemaType} this - * @see Customized Error Messages #error_messages_MongooseError-messages + * @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages * @api public */ @@ -258,7 +258,7 @@ SchemaNumber.prototype.min = function(value, message) { * @param {Number} maximum number * @param {String} [message] optional custom error message * @return {SchemaType} this - * @see Customized Error Messages #error_messages_MongooseError-messages + * @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages * @api public */ @@ -302,7 +302,7 @@ SchemaNumber.prototype.max = function(value, message) { * @param {Array} values allowed values * @param {String} [message] optional custom error message * @return {SchemaType} this - * @see Customized Error Messages #error_messages_MongooseError-messages + * @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages * @api public */ diff --git a/lib/schema/string.js b/lib/schema/string.js index daf9e97a14e..37993744263 100644 --- a/lib/schema/string.js +++ b/lib/schema/string.js @@ -201,7 +201,7 @@ SchemaString.checkRequired = SchemaType.checkRequired; * * @param {...String|Object} [args] enumeration values * @return {SchemaType} this - * @see Customized Error Messages #error_messages_MongooseError-messages + * @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages * @api public */ @@ -254,7 +254,7 @@ SchemaString.prototype.enum = function() { }; /** - * Adds a lowercase [setter](https://mongoosejs.com/docs/api/schematype.html#schematype_SchemaType-set). + * Adds a lowercase [setter](https://mongoosejs.com/docs/api/schematype.html#SchemaType.prototype.set()). * * #### Example: * @@ -293,7 +293,7 @@ SchemaString.prototype.lowercase = function(shouldApply) { }; /** - * Adds an uppercase [setter](https://mongoosejs.com/docs/api/schematype.html#schematype_SchemaType-set). + * Adds an uppercase [setter](https://mongoosejs.com/docs/api/schematype.html#SchemaType.prototype.set()). * * #### Example: * @@ -330,7 +330,7 @@ SchemaString.prototype.uppercase = function(shouldApply) { }; /** - * Adds a trim [setter](https://mongoosejs.com/docs/api/schematype.html#schematype_SchemaType-set). + * Adds a trim [setter](https://mongoosejs.com/docs/api/schematype.html#SchemaType.prototype.set()). * * The string value will be [trimmed](https://masteringjs.io/tutorials/fundamentals/trim-string) when set. * @@ -399,7 +399,7 @@ SchemaString.prototype.trim = function(shouldTrim) { * @param {Number} value minimum string length * @param {String} [message] optional custom error message * @return {SchemaType} this - * @see Customized Error Messages #error_messages_MongooseError-messages + * @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages * @api public */ @@ -455,7 +455,7 @@ SchemaString.prototype.minLength = SchemaString.prototype.minlength; * @param {Number} value maximum string length * @param {String} [message] optional custom error message * @return {SchemaType} this - * @see Customized Error Messages #error_messages_MongooseError-messages + * @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages * @api public */ @@ -518,7 +518,7 @@ SchemaString.prototype.maxLength = SchemaString.prototype.maxlength; * @param {RegExp} regExp regular expression to test against * @param {String} [message] optional custom error message * @return {SchemaType} this - * @see Customized Error Messages #error_messages_MongooseError-messages + * @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages * @api public */ diff --git a/lib/schematype.js b/lib/schematype.js index bc53c856431..4591e46785c 100644 --- a/lib/schematype.js +++ b/lib/schematype.js @@ -35,7 +35,7 @@ const setOptionsForDefaults = { _skipMarkModified: true }; * schema.path('name') instanceof SchemaType; // true * * @param {String} path - * @param {SchemaTypeOptions} [options] See [SchemaTypeOptions docs](/docs/api/schematypeoptions.html) + * @param {SchemaTypeOptions} [options] See [SchemaTypeOptions docs](https://mongoosejs.com/docs/api/schematypeoptions.html) * @param {String} [instance] * @api public */ @@ -532,7 +532,7 @@ SchemaType.prototype.sparse = function(bool) { /** * Defines this path as immutable. Mongoose prevents you from changing - * immutable paths unless the parent document has [`isNew: true`](/docs/api/document.html#document_Document-isNew). + * immutable paths unless the parent document has [`isNew: true`](https://mongoosejs.com/docs/api/document.html#Document.prototype.isNew()). * * #### Example: * @@ -550,7 +550,7 @@ SchemaType.prototype.sparse = function(bool) { * doc.name; // 'test', because `name` is immutable * * Mongoose also prevents changing immutable properties using `updateOne()` - * and `updateMany()` based on [strict mode](/docs/guide.html#strict). + * and `updateMany()` based on [strict mode](https://mongoosejs.com/docs/guide.html#strict). * * #### Example: * @@ -569,7 +569,7 @@ SchemaType.prototype.sparse = function(bool) { * * @param {Boolean} bool * @return {SchemaType} this - * @see isNew /docs/api/document.html#document_Document-isNew + * @see isNew https://mongoosejs.com/docs/api/document.html#Document.prototype.isNew() * @api public */ @@ -792,7 +792,7 @@ SchemaType.prototype.get = function(fn) { * must return `Boolean`. Returning `false` or throwing an error means * validation failed. * - * The error message argument is optional. If not passed, the [default generic error message template](./error.html#Error.prototype.name) will be used. + * The error message argument is optional. If not passed, the [default generic error message template](https://mongoosejs.com/docs/api/error.html#Error.messages) will be used. * * #### Example: * @@ -863,9 +863,9 @@ SchemaType.prototype.get = function(fn) { * * You might use asynchronous validators to retreive other documents from the database to validate against or to meet other I/O bound validation needs. * - * Validation occurs `pre('save')` or whenever you manually execute [document#validate](#document_Document-validate). + * Validation occurs `pre('save')` or whenever you manually execute [document#validate](https://mongoosejs.com/docs/api/document.html#Document.prototype.validate()). * - * If validation fails during `pre('save')` and no callback was passed to receive the error, an `error` event will be emitted on your Models associated db [connection](#connection_Connection), passing the validation error object along. + * If validation fails during `pre('save')` and no callback was passed to receive the error, an `error` event will be emitted on your Models associated db [connection](https://mongoosejs.com/docs/api/connection.html#Connection()), passing the validation error object along. * * const conn = mongoose.createConnection(..); * conn.on('error', handleError); @@ -926,7 +926,7 @@ SchemaType.prototype.validate = function(obj, message, type) { if (!utils.isPOJO(arg)) { const msg = 'Invalid validator. Received (' + typeof arg + ') ' + arg - + '. See https://mongoosejs.com/docs/api/schematype.html#schematype_SchemaType-validate'; + + '. See https://mongoosejs.com/docs/api/schematype.html#SchemaType.prototype.validate()'; throw new Error(msg); } @@ -993,13 +993,13 @@ SchemaType.prototype.validate = function(obj, message, type) { * @param {Function} [options.ErrorConstructor] custom error constructor. The constructor receives 1 parameter, an object containing the validator properties. * @param {String} [message] optional custom error message * @return {SchemaType} this - * @see Customized Error Messages ./error.html#Error.prototype.name - * @see SchemaArray#checkRequired ./schemaarray.html#SchemaArray.prototype.checkRequired() - * @see SchemaBoolean#checkRequired ./schemaboolean.html#SchemaBoolean.prototype.checkRequired() - * @see SchemaBuffer#checkRequired ./schemabuffer.html#SchemaBuffer.prototype.checkRequired() - * @see SchemaNumber#checkRequired ./schemanumber.html#SchemaNumber.prototype.checkRequired() - * @see SchemaObjectId#checkRequired ./schemaobjectid.html#ObjectId.prototype.checkRequired() - * @see SchemaString#checkRequired ./schemastring.html#SchemaString.prototype.checkRequired() + * @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages + * @see SchemaArray#checkRequired https://mongoosejs.com/docs/api/schemaarray.html#SchemaArray.prototype.checkRequired() + * @see SchemaBoolean#checkRequired https://mongoosejs.com/docs/api/schemaboolean.html#SchemaBoolean.prototype.checkRequired() + * @see SchemaBuffer#checkRequired https://mongoosejs.com/docs/api/schemabuffer.html#SchemaBuffer.prototype.checkRequired() + * @see SchemaNumber#checkRequired https://mongoosejs.com/docs/api/schemanumber.html#SchemaNumber.prototype.checkRequired() + * @see SchemaObjectId#checkRequired https://mongoosejs.com/docs/api/schemaobjectid.html#ObjectId.prototype.checkRequired() + * @see SchemaString#checkRequired https://mongoosejs.com/docs/api/schemastring.html#SchemaString.prototype.checkRequired() * @api public */ diff --git a/lib/types/array/methods/index.js b/lib/types/array/methods/index.js index ef262d58834..d7aae6567d9 100644 --- a/lib/types/array/methods/index.js +++ b/lib/types/array/methods/index.js @@ -105,7 +105,7 @@ const methods = { * #### Note: * * _Calling this multiple times on an array before saving sends the same command as calling it once._ - * _This update is implemented using the MongoDB [$pop](https://www.mongodb.org/display/DOCS/Updating/#Updating-%24pop) method which enforces this restriction._ + * _This update is implemented using the MongoDB [$pop](https://www.mongodb.com/docs/manual/reference/operator/update/pop/) method which enforces this restriction._ * * doc.array = [1,2,3]; * @@ -130,7 +130,7 @@ const methods = { * @memberOf MongooseArray * @instance * @method $shift - * @see mongodb https://www.mongodb.org/display/DOCS/Updating/#Updating-%24pop + * @see mongodb https://www.mongodb.com/docs/manual/reference/operator/update/pop/ */ $shift() { @@ -153,7 +153,7 @@ const methods = { * #### NOTE: * * _Calling this multiple times on an array before saving sends the same command as calling it once._ - * _This update is implemented using the MongoDB [$pop](https://www.mongodb.org/display/DOCS/Updating/#Updating-%24pop) method which enforces this restriction._ + * _This update is implemented using the MongoDB [$pop](https://www.mongodb.com/docs/manual/reference/operator/update/pop/) method which enforces this restriction._ * * doc.array = [1,2,3]; * @@ -178,7 +178,7 @@ const methods = { * @method $pop * @memberOf MongooseArray * @instance - * @see mongodb https://www.mongodb.org/display/DOCS/Updating/#Updating-%24pop + * @see mongodb https://www.mongodb.com/docs/manual/reference/operator/update/pop/ * @method $pop * @memberOf MongooseArray */ @@ -547,7 +547,7 @@ const methods = { * * _marks the entire array as modified which will pass the entire thing to $set potentially overwriting any changes that happen between when you retrieved the object and when you save it._ * - * @see MongooseArray#$pop #types_array_MongooseArray-%24pop + * @see MongooseArray#$pop https://mongoosejs.com/docs/api/array.html#MongooseArray.prototype.$pop() * @api public * @method pop * @memberOf MongooseArray @@ -563,7 +563,7 @@ const methods = { /** * Pulls items from the array atomically. Equality is determined by casting * the provided value to an embedded document and comparing using - * [the `Document.equals()` function.](/docs/api/document.html#document_Document-equals) + * [the `Document.equals()` function.](https://mongoosejs.com/docs/api/document.html#Document.prototype.equals()) * * #### Example: * @@ -585,7 +585,7 @@ const methods = { * The first pull call will result in a atomic operation on the database, if pull is called repeatedly without saving the document, a $set operation is used on the complete array instead, overwriting possible changes that happened on the database in the meantime. * * @param {...any} [args] - * @see mongodb https://www.mongodb.org/display/DOCS/Updating/#Updating-%24pull + * @see mongodb https://www.mongodb.com/docs/manual/reference/operator/update/pull/ * @api public * @method pull * @memberOf MongooseArray @@ -716,10 +716,10 @@ const methods = { }, /** - * Alias of [pull](#mongoosearray_MongooseArray-pull) + * Alias of [pull](https://mongoosejs.com/docs/api/array.html#MongooseArray.prototype.pull()) * - * @see MongooseArray#pull #types_array_MongooseArray-pull - * @see mongodb https://www.mongodb.org/display/DOCS/Updating/#Updating-%24pull + * @see MongooseArray#pull https://mongoosejs.com/docs/api/array.html#MongooseArray.prototype.pull() + * @see mongodb https://www.mongodb.com/docs/manual/reference/operator/update/pull/ * @api public * @memberOf MongooseArray * @instance @@ -806,7 +806,7 @@ const methods = { * @api public * @method sort * @memberOf MongooseArray - * @see https://masteringjs.io/tutorials/fundamentals/array-sort + * @see MasteringJS: Array sort https://masteringjs.io/tutorials/fundamentals/array-sort */ sort() { @@ -826,7 +826,7 @@ const methods = { * @api public * @method splice * @memberOf MongooseArray - * @see https://masteringjs.io/tutorials/fundamentals/array-splice + * @see MasteringJS: Array splice https://masteringjs.io/tutorials/fundamentals/array-splice */ splice() { diff --git a/lib/virtualtype.js b/lib/virtualtype.js index 6efa01c096e..87c912fdd70 100644 --- a/lib/virtualtype.js +++ b/lib/virtualtype.js @@ -13,12 +13,12 @@ const utils = require('./utils'); * fullname instanceof mongoose.VirtualType // true * * @param {Object} options - * @param {String|Function} [options.ref] if `ref` is not nullish, this becomes a [populated virtual](/docs/populate.html#populate-virtuals) + * @param {String|Function} [options.ref] if `ref` is not nullish, this becomes a [populated virtual](https://mongoosejs.com/docs/populate.html#populate-virtuals) * @param {String|Function} [options.localField] the local field to populate on if this is a populated virtual. * @param {String|Function} [options.foreignField] the foreign field to populate on if this is a populated virtual. * @param {Boolean} [options.justOne=false] by default, a populated virtual is an array. If you set `justOne`, the populated virtual will be a single doc or `null`. * @param {Boolean} [options.getters=false] if you set this to `true`, Mongoose will call any custom getters you defined on this virtual - * @param {Boolean} [options.count=false] if you set this to `true`, `populate()` will set this virtual to the number of populated documents, as opposed to the documents themselves, using [`Query#countDocuments()`](/docs/api/query.html#query_Query-countDocuments) + * @param {Boolean} [options.count=false] if you set this to `true`, `populate()` will set this virtual to the number of populated documents, as opposed to the documents themselves, using [`Query#countDocuments()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.countDocuments()) * @param {Object|Function} [options.match=null] add an extra match condition to `populate()` * @param {Number} [options.limit=null] add a default `limit` to the `populate()` query * @param {Number} [options.skip=null] add a default `skip` to the `populate()` query diff --git a/scripts/website.js b/scripts/website.js index 03e3393ec58..0ef9598c708 100644 --- a/scripts/website.js +++ b/scripts/website.js @@ -267,6 +267,62 @@ const cpc = ` /** Alias to not execute "promisify" often */ const pugRender = promisify(pug.render); +/** Find all urls that are href's and start with "https://mongoosejs.com" */ +const mongooseComRegex = /(?:href=")(https:\/\/mongoosejs\.com\/?)/g; +/** Regex to detect a versioned path */ +const versionedDocs = /docs\/\d/; + +/** + * Map urls (https://mongoosejs.com/) to local paths + * @param {String} block The String block to look for urls + * @param {String} currentUrl The URL the block is for (non-versioned) + */ +function mapURLs(block, currentUrl) { + let match; + + let out = ''; + let lastIndex = 0; + + while ((match = mongooseComRegex.exec(block)) !== null) { + // console.log("match", match); + // cant just use "match.index" byitself, because of the extra "href=\"" condition, which is not factored in in "match.index" + let startIndex = match.index + match[0].length - match[1].length; + out += block.slice(lastIndex, startIndex); + lastIndex = startIndex + match[1].length; + + // somewhat primitive gathering of the url, but should be enough for now + let fullUrl = /^\/[^"]+/.exec(block.slice(lastIndex-1)); + + let noPrefix = false; + + if (fullUrl) { + // extra processing to only use "#otherId" instead of using full url for the same page + // at least firefox does not make a difference between a full path and just "#", but it makes debugging paths easier + if (fullUrl[0].startsWith(currentUrl)) { + let indexMatch = /#/.exec(fullUrl); + + if (indexMatch) { + lastIndex += indexMatch.index - 1; + noPrefix = true; + } + } + } + + if (!noPrefix) { + // map all to the versioned-path, unless a explicit version is given + if (!versionedDocs.test(block.slice(lastIndex, lastIndex+10))) { + out += versionObj.versionedPath + "/"; + } else { + out += "/"; + } + } + } + + out += block.slice(lastIndex); + + return out; +} + /** * Render a given file with the given options * @param {String} filename The documentation file path to render @@ -275,6 +331,7 @@ const pugRender = promisify(pug.render); * @returns */ async function pugify(filename, options, isReload = false) { + /** Path for the output file */ let newfile = undefined; options = options || {}; options.package = pkg; @@ -325,6 +382,9 @@ async function pugify(filename, options, isReload = false) { newfile = newfile || filename.replace('.pug', '.html'); + /** Unversioned final documentation path */ + const docsPath = newfile; + if (versionObj.versionedDeploy) { newfile = path.resolve(cwd, path.join('.', versionObj.versionedPath), path.relative(cwd, newfile)); await fs.promises.mkdir(path.dirname(newfile), {recursive:true}); @@ -336,11 +396,13 @@ async function pugify(filename, options, isReload = false) { options.opencollectiveSponsors = opencollectiveSponsors; - const str = await pugRender(contents, options).catch(console.error); + let str = await pugRender(contents, options).catch(console.error); if (typeof str !== "string") { return; } + + str = mapURLs(str, '/' + path.relative(cwd, docsPath)) await fs.promises.writeFile(newfile, str).catch((err) => { console.error('could not write', err.stack);