Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Touch-up JSDOC of some more files #12140

Merged
merged 8 commits into from Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/connections.md
Expand Up @@ -73,7 +73,7 @@ mongoose.set('bufferCommands', false);
Note that buffering is also responsible for waiting until Mongoose
creates collections if you use the [`autoCreate` option](/docs/guide.html#autoCreate).
If you disable buffering, you should also disable the `autoCreate`
option and use [`createCollection()`](/docs/api/model.html#model_Model.createCollection)
option and use [`createCollection()`](/docs/api/model.html#model_Model-createCollection)
to create [capped collections](/docs/guide.html#capped) or
[collections with collations](/docs/guide.html#collation).

Expand Down
8 changes: 4 additions & 4 deletions docs/deprecations.md
Expand Up @@ -28,7 +28,7 @@ deleteMany, or bulkWrite instead.
```

To remove this deprecation warning, replace any usage of `remove()` with
`deleteMany()`, _unless_ you specify the [`single` option to `remove()`](/docs/api.html#model_Model.remove). The `single`
`deleteMany()`, _unless_ you specify the [`single` option to `remove()`](/docs/api.html#model_Model-remove). The `single`
option limited `remove()` to deleting at most one document, so you should
replace `remove(filter, { single: true })` with `deleteOne(filter)`.

Expand All @@ -46,9 +46,9 @@ MyModel.deleteOne({ answer: 42 });

<h2 id="update"><a href="#update"><code>update()</code></a></h2>

Like `remove()`, the [`update()` function](/docs/api.html#model_Model.update) is deprecated in favor
of the more explicit [`updateOne()`](/docs/api.html#model_Model.updateOne), [`updateMany()`](/docs/api.html#model_Model.updateMany), and [`replaceOne()`](/docs/api.html#model_Model.replaceOne) functions. You should replace
`update()` with `updateOne()`, unless you use the [`multi` or `overwrite` options](/docs/api.html#model_Model.update).
Like `remove()`, the [`update()` function](/docs/api.html#model_Model-update) is deprecated in favor
of the more explicit [`updateOne()`](/docs/api.html#model_Model-updateOne), [`updateMany()`](/docs/api.html#model_Model-updateMany), and [`replaceOne()`](/docs/api.html#model_Model-replaceOne) functions. You should replace
`update()` with `updateOne()`, unless you use the [`multi` or `overwrite` options](/docs/api.html#model_Model-update).

```
collection.update is deprecated. Use updateOne, updateMany, or bulkWrite
Expand Down
6 changes: 3 additions & 3 deletions docs/documents.md
Expand Up @@ -35,7 +35,7 @@ going through a model.

<h2 id="retrieving"><a href="#retrieving">Retrieving</a></h2>

When you load documents from MongoDB using model functions like [`findOne()`](api.html#model_Model.findOne),
When you load documents from MongoDB using model functions like [`findOne()`](api.html#model_Model-findOne),
you get a Mongoose document back.

```javascript
Expand Down Expand Up @@ -151,7 +151,7 @@ doc.overwrite({ name: 'Jean-Luc Picard' });
await doc.save();
```

The other way is to use [`Model.replaceOne()`](/docs/api/model.html#model_Model.replaceOne).
The other way is to use [`Model.replaceOne()`](/docs/api/model.html#model_Model-replaceOne).

```javascript
// Sets `name` and unsets all other properties
Expand All @@ -161,4 +161,4 @@ await Person.replaceOne({ _id }, { name: 'Jean-Luc Picard' });
### Next Up

Now that we've covered Documents, let's take a look at
[Subdocuments](/docs/subdocs.html).
[Subdocuments](/docs/subdocs.html).
14 changes: 7 additions & 7 deletions docs/guide.md
Expand Up @@ -172,7 +172,7 @@ dog.findSimilarTypes((err, dogs) => {
});
```

* Overwriting a default mongoose document method may lead to unpredictable results. See [this](./api.html#schema_Schema.reserved) for more details.
* Overwriting a default mongoose document method may lead to unpredictable results. See [this](./api.html#schema_Schema-reserved) for more details.
* The example above uses the `Schema.methods` object directly to save an instance method. You can also use the `Schema.method()` helper as described [here](./api.html#schema_Schema-method).
* Do **not** declare methods using ES6 arrow functions (`=>`). Arrow functions [explicitly prevent binding `this`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#No_binding_of_this), so your method will **not** have access to the document and the above examples will not work.

Expand Down Expand Up @@ -300,7 +300,7 @@ Animal.on('index', error => {
});
```

See also the [Model#ensureIndexes](./api.html#model_Model.ensureIndexes) method.
See also the [Model#ensureIndexes](./api.html#model_Model-ensureIndexes) method.

<h3 id="virtuals"><a href="#virtuals">Virtuals</a></h3>

Expand Down Expand Up @@ -468,9 +468,9 @@ Valid options:

<h3 id="autoIndex"><a href="#autoIndex">option: autoIndex</a></h3>

By default, Mongoose's [`init()` function](/docs/api.html#model_Model.init)
By default, Mongoose's [`init()` function](/docs/api.html#model_Model-init)
creates all the indexes defined in your model's schema by calling
[`Model.createIndexes()`](/docs/api.html#model_Model.createIndexes)
[`Model.createIndexes()`](/docs/api.html#model_Model-createIndexes)
after you successfully connect to MongoDB. Creating indexes automatically is
great for development and test environments. But index builds can also create
significant load on your production database. If you want to manage indexes
Expand Down Expand Up @@ -561,7 +561,7 @@ new Schema({..}, { capped: { size: 1024, max: 1000, autoIndexId: true } });
<h3 id="collection"><a href="#collection">option: collection</a></h3>

Mongoose by default produces a collection name by passing the model name to
the [utils.toCollectionName](./api.html#utils_exports.toCollectionName) method.
the [utils.toCollectionName](./api.html#utils_exports-toCollectionName) method.
This method pluralizes the name. Set this option if you need a different name
for your collection.

Expand Down Expand Up @@ -613,7 +613,7 @@ console.log(p.id); // undefined

Mongoose assigns each of your schemas an `_id` field by default if one
is not passed into the [Schema](/docs/api.html#schema-js) constructor.
The type assigned is an [ObjectId](/docs/api.html#schema_Schema.Types)
The type assigned is an [ObjectId](/docs/api.html#schema_Schema-Types)
to coincide with MongoDB's default behavior. If you don't want an `_id`
added to your schema at all, you may disable it using this option.

Expand Down Expand Up @@ -1165,7 +1165,7 @@ await Thing.updateOne({}, { $set: { name: 'Test' } });
await Thing.findOneAndUpdate({}, { $set: { name: 'Test2' } });

// Mongoose also adds timestamps to bulkWrite() operations
// See https://mongoosejs.com/docs/api.html#model_Model.bulkWrite
// See https://mongoosejs.com/docs/api.html#model_Model-bulkWrite
await Thing.bulkWrite([
insertOne: {
document: {
Expand Down
14 changes: 7 additions & 7 deletions docs/middleware.md
Expand Up @@ -47,22 +47,22 @@ In query middleware functions, `this` refers to the query.
* [findOneAndRemove](./api.html#query_Query-findOneAndRemove)
* [findOneAndReplace](./api/query.html#query_Query-findOneAndReplace)
* [findOneAndUpdate](./api.html#query_Query-findOneAndUpdate)
* [remove](./api.html#model_Model.remove)
* [remove](./api.html#model_Model-remove)
* [replaceOne](./api/query.html#query_Query-replaceOne)
* [update](./api.html#query_Query-update)
* [updateOne](./api.html#query_Query-updateOne)
* [updateMany](./api.html#query_Query-updateMany)

Aggregate middleware is for `MyModel.aggregate()`. Aggregate middleware
executes when you call `exec()` on an aggregate object.
In aggregate middleware, `this` refers to the [aggregation object](./api.html#model_Model.aggregate).
In aggregate middleware, `this` refers to the [aggregation object](./api.html#model_Model-aggregate).

* [aggregate](./api.html#model_Model.aggregate)
* [aggregate](./api.html#model_Model-aggregate)

Model middleware is supported for the following model functions.
In model middleware functions, `this` refers to the model.

* [insertMany](./api.html#model_Model.insertMany)
* [insertMany](./api.html#model_Model-insertMany)

All middleware types support pre and post hooks.
How pre and post hooks work is described in more detail below.
Expand All @@ -79,7 +79,7 @@ This means that both `doc.updateOne()` and `Model.updateOne()` trigger
`updateOne` or `deleteOne` middleware as document middleware, use
`schema.pre('updateOne', { document: true, query: false })`.

**Note:** The [`create()`](./api.html#model_Model.create) function fires `save()` hooks.
**Note:** The [`create()`](./api.html#model_Model-create) function fires `save()` hooks.

<h3 id="pre"><a href="#pre">Pre</a></h3>

Expand Down Expand Up @@ -311,7 +311,7 @@ Model.remove();
You can pass options to [`Schema.pre()`](/docs/api.html#schema_Schema-pre)
and [`Schema.post()`](/docs/api.html#schema_Schema-post) to switch whether
Mongoose calls your `remove()` hook for [`Document.remove()`](/docs/api.html#model_Model-remove)
or [`Model.remove()`](/docs/api.html#model_Model.remove). Note here that you need to set both `document` and `query` properties in the passed object:
or [`Model.remove()`](/docs/api.html#model_Model-remove). Note here that you need to set both `document` and `query` properties in the passed object:

```javascript
// Only document middleware
Expand Down Expand Up @@ -462,7 +462,7 @@ function call will still error out.

<h3 id="aggregate"><a href="#aggregate">Aggregation Hooks</a></h3>

You can also define hooks for the [`Model.aggregate()` function](api.html#model_Model.aggregate).
You can also define hooks for the [`Model.aggregate()` function](api.html#model_Model-aggregate).
In aggregation middleware functions, `this` refers to the [Mongoose `Aggregate` object](api.html#Aggregate).
For example, suppose you're implementing soft deletes on a `Customer` model
by adding an `isDeleted` property. To make sure `aggregate()` calls only look
Expand Down
4 changes: 2 additions & 2 deletions docs/migrating_to_5.md
Expand Up @@ -465,7 +465,7 @@ In Mongoose 5.x, the above code will correctly overwrite `'baseball'` with `{ $n
</a></h3>

Mongoose 5.x uses version 3.x of the [MongoDB Node.js driver](http://npmjs.com/package/mongodb). MongoDB driver 3.x changed the format of
the result of [`bulkWrite()` calls](/docs/api.html#model_Model.bulkWrite) so there is no longer a top-level `nInserted`, `nModified`, etc. property. The new result object structure is [described here](http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#~BulkWriteOpResult).
the result of [`bulkWrite()` calls](/docs/api.html#model_Model-bulkWrite) so there is no longer a top-level `nInserted`, `nModified`, etc. property. The new result object structure is [described here](http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#~BulkWriteOpResult).

```javascript
const Model = mongoose.model('Test', new Schema({ name: String }));
Expand Down Expand Up @@ -545,4 +545,4 @@ If this is blocking you from upgrading, you can set the `tlsInsecure` option to

```javascript
mongoose.connect(uri, { tlsInsecure: false }); // Opt out of additional SSL validation
```
```
8 changes: 4 additions & 4 deletions docs/models.md
Expand Up @@ -75,7 +75,7 @@ const Tank = connection.model('Tank', yourSchema);

### Querying

Finding documents is easy with Mongoose, which supports the [rich](http://www.mongodb.org/display/DOCS/Advanced+Queries) query syntax of MongoDB. Documents can be retrieved using a `model`'s [find](./api.html#model_Model.find), [findById](./api.html#model_Model.findById), [findOne](./api.html#model_Model.findOne), or [where](./api.html#model_Model.where) static methods.
Finding documents is easy with Mongoose, which supports the [rich](http://www.mongodb.org/display/DOCS/Advanced+Queries) query syntax of MongoDB. Documents can be retrieved using a `model`'s [find](./api.html#model_Model-find), [findById](./api.html#model_Model-findById), [findOne](./api.html#model_Model-findOne), or [where](./api.html#model_Model-where) static methods.

```javascript
Tank.find({ size: 'small' }).where('createdDate').gt(oneYearAgo).exec(callback);
Expand All @@ -99,7 +99,7 @@ Tank.deleteOne({ size: 'large' }, function (err) {

Each `model` has its own `update` method for modifying documents in the
database without returning them to your application. See the
[API](./api.html#model_Model.updateOne) docs for more detail.
[API](./api.html#model_Model-updateOne) docs for more detail.

```javascript
Tank.updateOne({ size: 'large' }, { name: 'T-90' }, function(err, res) {
Expand All @@ -109,7 +109,7 @@ Tank.updateOne({ size: 'large' }, { name: 'T-90' }, function(err, res) {
```

_If you want to update a single document in the db and return it to your
application, use [findOneAndUpdate](./api.html#model_Model.findOneAndUpdate)
application, use [findOneAndUpdate](./api.html#model_Model-findOneAndUpdate)
instead._

### Change Streams
Expand Down Expand Up @@ -156,7 +156,7 @@ You can read more about [change streams in mongoose in this blog post](http://th

### Yet more

The [API docs](./api.html#model_Model) cover many additional methods available like [count](./api.html#model_Model.count), [mapReduce](./api.html#model_Model.mapReduce), [aggregate](./api.html#model_Model.aggregate), and [more](./api.html#model_Model.findOneAndRemove).
The [API docs](./api.html#model_Model) cover many additional methods available like [count](./api.html#model_Model-count), [mapReduce](./api.html#model_Model-mapReduce), [aggregate](./api.html#model_Model-aggregate), and [more](./api.html#model_Model-findOneAndRemove).

### Next Up

Expand Down
6 changes: 3 additions & 3 deletions docs/populate.md
Expand Up @@ -407,8 +407,8 @@ person.populated('fans'); // Array of ObjectIds
<h3 id="populate_multiple_documents"><a href="#populate_multiple_documents">Populating multiple existing documents</a></h3>

If we have one or many mongoose documents or even plain objects
(_like [mapReduce](./api.html#model_Model.mapReduce) output_), we may
populate them using the [Model.populate()](./api.html#model_Model.populate)
(_like [mapReduce](./api.html#model_Model-mapReduce) output_), we may
populate them using the [Model.populate()](./api.html#model_Model-populate)
method. This is what `Document#populate()`
and `Query#populate()` use to populate documents.

Expand Down Expand Up @@ -475,7 +475,7 @@ This is known as a "cross-database populate," because it enables you to
populate across MongoDB databases and even across MongoDB instances.

If you don't have access to the model instance when defining your `eventSchema`,
you can also pass [the model instance as an option to `populate()`](/docs/api/model.html#model_Model.populate).
you can also pass [the model instance as an option to `populate()`](/docs/api/model.html#model_Model-populate).

```javascript
const events = await Event.
Expand Down
34 changes: 17 additions & 17 deletions docs/queries.md
Expand Up @@ -5,21 +5,21 @@ for [CRUD operations](https://en.wikipedia.org/wiki/Create,_read,_update_and_del
Each of these functions returns a
[mongoose `Query` object](http://mongoosejs.com/docs/api.html#Query).

- [`Model.deleteMany()`](/docs/api.html#model_Model.deleteMany)
- [`Model.deleteOne()`](/docs/api.html#model_Model.deleteOne)
- [`Model.find()`](/docs/api.html#model_Model.find)
- [`Model.findById()`](/docs/api.html#model_Model.findById)
- [`Model.findByIdAndDelete()`](/docs/api.html#model_Model.findByIdAndDelete)
- [`Model.findByIdAndRemove()`](/docs/api.html#model_Model.findByIdAndRemove)
- [`Model.findByIdAndUpdate()`](/docs/api.html#model_Model.findByIdAndUpdate)
- [`Model.findOne()`](/docs/api.html#model_Model.findOne)
- [`Model.findOneAndDelete()`](/docs/api.html#model_Model.findOneAndDelete)
- [`Model.findOneAndRemove()`](/docs/api.html#model_Model.findOneAndRemove)
- [`Model.findOneAndReplace()`](/docs/api.html#model_Model.findOneAndReplace)
- [`Model.findOneAndUpdate()`](/docs/api.html#model_Model.findOneAndUpdate)
- [`Model.replaceOne()`](/docs/api.html#model_Model.replaceOne)
- [`Model.updateMany()`](/docs/api.html#model_Model.updateMany)
- [`Model.updateOne()`](/docs/api.html#model_Model.updateOne)
- [`Model.deleteMany()`](/docs/api.html#model_Model-deleteMany)
- [`Model.deleteOne()`](/docs/api.html#model_Model-deleteOne)
- [`Model.find()`](/docs/api.html#model_Model-find)
- [`Model.findById()`](/docs/api.html#model_Model-findById)
- [`Model.findByIdAndDelete()`](/docs/api.html#model_Model-findByIdAndDelete)
- [`Model.findByIdAndRemove()`](/docs/api.html#model_Model-findByIdAndRemove)
- [`Model.findByIdAndUpdate()`](/docs/api.html#model_Model-findByIdAndUpdate)
- [`Model.findOne()`](/docs/api.html#model_Model-findOne)
- [`Model.findOneAndDelete()`](/docs/api.html#model_Model-findOneAndDelete)
- [`Model.findOneAndRemove()`](/docs/api.html#model_Model-findOneAndRemove)
- [`Model.findOneAndReplace()`](/docs/api.html#model_Model-findOneAndReplace)
- [`Model.findOneAndUpdate()`](/docs/api.html#model_Model-findOneAndUpdate)
- [`Model.replaceOne()`](/docs/api.html#model_Model-replaceOne)
- [`Model.updateMany()`](/docs/api.html#model_Model-updateMany)
- [`Model.updateOne()`](/docs/api.html#model_Model-updateOne)

A mongoose query can be executed in one of two ways. First, if you
pass in a `callback` function, Mongoose will execute the query asynchronously
Expand Down Expand Up @@ -55,7 +55,7 @@ Mongoose executed the query and passed the results to `callback`. All callbacks
`callback(error, result)`. If an error occurs executing the query, the `error` parameter will contain an error document, and `result`
will be null. If the query is successful, the `error` parameter will be null, and the `result` will be populated with the results of the query.

Anywhere a callback is passed to a query in Mongoose, the callback follows the pattern `callback(error, results)`. What `results` is depends on the operation: For `findOne()` it is a [potentially-null single document](./api.html#model_Model.findOne), `find()` a [list of documents](./api.html#model_Model.find), `count()` [the number of documents](./api.html#model_Model.count), `update()` the [number of documents affected](./api.html#model_Model.update), etc. The [API docs for Models](./api.html#model-js) provide more detail on what is passed to the callbacks.
Anywhere a callback is passed to a query in Mongoose, the callback follows the pattern `callback(error, results)`. What `results` is depends on the operation: For `findOne()` it is a [potentially-null single document](./api.html#model_Model-findOne), `find()` a [list of documents](./api.html#model_Model-find), `count()` [the number of documents](./api.html#model_Model-count), `update()` the [number of documents affected](./api.html#model_Model-update), etc. The [API docs for Models](./api.html#model-js) provide more detail on what is passed to the callbacks.

Now let's look at what happens when no `callback` is passed:

Expand Down Expand Up @@ -212,7 +212,7 @@ However, just because you can use `aggregate()` doesn't mean you should.
In general, you should use queries where possible, and only use `aggregate()`
when you absolutely need to.

Unlike query results, Mongoose does **not** [`hydrate()`](/docs/api/model.html#model_Model.hydrate)
Unlike query results, Mongoose does **not** [`hydrate()`](/docs/api/model.html#model_Model-hydrate)
aggregation results. Aggregation results are always POJOs, not Mongoose
documents.

Expand Down
2 changes: 1 addition & 1 deletion docs/schematypes.md
Expand Up @@ -467,7 +467,7 @@ console.log(new M({ b: 'nay' }).b); // false

<h4 id="arrays">Arrays</h4>

Mongoose supports arrays of [SchemaTypes](./api.html#schema_Schema.Types)
Mongoose supports arrays of [SchemaTypes](./api.html#schema_Schema-Types)
and arrays of [subdocuments](./subdocs.html). Arrays of SchemaTypes are
also called _primitive arrays_, and arrays of subdocuments are also called
_document arrays_.
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/lean.md
@@ -1,7 +1,7 @@
# Faster Mongoose Queries With Lean

The [lean option](/docs/api.html#query_Query-lean) tells Mongoose to skip
[hydrating](/docs/api.html#model_Model.hydrate) the result documents. This
[hydrating](/docs/api.html#model_Model-hydrate) the result documents. This
makes queries faster and less memory intensive, but the result documents are
plain old JavaScript objects (POJOs), **not** [Mongoose documents](/docs/documents.html).
In this tutorial, you'll learn more about the tradeoffs of using `lean()`.
Expand Down Expand Up @@ -139,4 +139,4 @@ schema.virtual('lowercase', function() {
this.name; // Works
this.get('name'); // Crashes because `this` is not a Mongoose document.
});
```
```