Skip to content

Commit 7ff925b

Browse files
authored
Merge pull request #12140 from hasezoey/jsdoc
Touch-up JSDOC of some more files
2 parents 2b0c5e1 + eed5840 commit 7ff925b

25 files changed

+424
-319
lines changed

docs/connections.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ mongoose.set('bufferCommands', false);
7373
Note that buffering is also responsible for waiting until Mongoose
7474
creates collections if you use the [`autoCreate` option](/docs/guide.html#autoCreate).
7575
If you disable buffering, you should also disable the `autoCreate`
76-
option and use [`createCollection()`](/docs/api/model.html#model_Model.createCollection)
76+
option and use [`createCollection()`](/docs/api/model.html#model_Model-createCollection)
7777
to create [capped collections](/docs/guide.html#capped) or
7878
[collections with collations](/docs/guide.html#collation).
7979

docs/deprecations.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ deleteMany, or bulkWrite instead.
2828
```
2929

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

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

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

49-
Like `remove()`, the [`update()` function](/docs/api.html#model_Model.update) is deprecated in favor
50-
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
51-
`update()` with `updateOne()`, unless you use the [`multi` or `overwrite` options](/docs/api.html#model_Model.update).
49+
Like `remove()`, the [`update()` function](/docs/api.html#model_Model-update) is deprecated in favor
50+
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
51+
`update()` with `updateOne()`, unless you use the [`multi` or `overwrite` options](/docs/api.html#model_Model-update).
5252

5353
```
5454
collection.update is deprecated. Use updateOne, updateMany, or bulkWrite

docs/documents.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ going through a model.
3535

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

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

4141
```javascript
@@ -151,7 +151,7 @@ doc.overwrite({ name: 'Jean-Luc Picard' });
151151
await doc.save();
152152
```
153153

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

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

163163
Now that we've covered Documents, let's take a look at
164-
[Subdocuments](/docs/subdocs.html).
164+
[Subdocuments](/docs/subdocs.html).

docs/guide.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ dog.findSimilarTypes((err, dogs) => {
172172
});
173173
```
174174

175-
* Overwriting a default mongoose document method may lead to unpredictable results. See [this](./api.html#schema_Schema.reserved) for more details.
175+
* Overwriting a default mongoose document method may lead to unpredictable results. See [this](./api.html#schema_Schema-reserved) for more details.
176176
* 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).
177177
* 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.
178178

@@ -300,7 +300,7 @@ Animal.on('index', error => {
300300
});
301301
```
302302

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

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

@@ -468,9 +468,9 @@ Valid options:
468468

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

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

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

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

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

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

11671167
// Mongoose also adds timestamps to bulkWrite() operations
1168-
// See https://mongoosejs.com/docs/api.html#model_Model.bulkWrite
1168+
// See https://mongoosejs.com/docs/api.html#model_Model-bulkWrite
11691169
await Thing.bulkWrite([
11701170
insertOne: {
11711171
document: {

docs/middleware.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,22 @@ In query middleware functions, `this` refers to the query.
4747
* [findOneAndRemove](./api.html#query_Query-findOneAndRemove)
4848
* [findOneAndReplace](./api/query.html#query_Query-findOneAndReplace)
4949
* [findOneAndUpdate](./api.html#query_Query-findOneAndUpdate)
50-
* [remove](./api.html#model_Model.remove)
50+
* [remove](./api.html#model_Model-remove)
5151
* [replaceOne](./api/query.html#query_Query-replaceOne)
5252
* [update](./api.html#query_Query-update)
5353
* [updateOne](./api.html#query_Query-updateOne)
5454
* [updateMany](./api.html#query_Query-updateMany)
5555

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

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

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

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

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

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

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

@@ -311,7 +311,7 @@ Model.remove();
311311
You can pass options to [`Schema.pre()`](/docs/api.html#schema_Schema-pre)
312312
and [`Schema.post()`](/docs/api.html#schema_Schema-post) to switch whether
313313
Mongoose calls your `remove()` hook for [`Document.remove()`](/docs/api.html#model_Model-remove)
314-
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:
314+
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:
315315

316316
```javascript
317317
// Only document middleware
@@ -462,7 +462,7 @@ function call will still error out.
462462

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

465-
You can also define hooks for the [`Model.aggregate()` function](api.html#model_Model.aggregate).
465+
You can also define hooks for the [`Model.aggregate()` function](api.html#model_Model-aggregate).
466466
In aggregation middleware functions, `this` refers to the [Mongoose `Aggregate` object](api.html#Aggregate).
467467
For example, suppose you're implementing soft deletes on a `Customer` model
468468
by adding an `isDeleted` property. To make sure `aggregate()` calls only look

docs/migrating_to_5.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ In Mongoose 5.x, the above code will correctly overwrite `'baseball'` with `{ $n
465465
</a></h3>
466466

467467
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
468-
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).
468+
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).
469469

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

546546
```javascript
547547
mongoose.connect(uri, { tlsInsecure: false }); // Opt out of additional SSL validation
548-
```
548+
```

docs/models.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const Tank = connection.model('Tank', yourSchema);
7575

7676
### Querying
7777

78-
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.
78+
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.
7979

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

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

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

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

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

157157
### Yet more
158158

159-
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).
159+
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).
160160

161161
### Next Up
162162

docs/populate.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@ person.populated('fans'); // Array of ObjectIds
407407
<h3 id="populate_multiple_documents"><a href="#populate_multiple_documents">Populating multiple existing documents</a></h3>
408408

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

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

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

480480
```javascript
481481
const events = await Event.

docs/queries.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ for [CRUD operations](https://en.wikipedia.org/wiki/Create,_read,_update_and_del
55
Each of these functions returns a
66
[mongoose `Query` object](http://mongoosejs.com/docs/api.html#Query).
77

8-
- [`Model.deleteMany()`](/docs/api.html#model_Model.deleteMany)
9-
- [`Model.deleteOne()`](/docs/api.html#model_Model.deleteOne)
10-
- [`Model.find()`](/docs/api.html#model_Model.find)
11-
- [`Model.findById()`](/docs/api.html#model_Model.findById)
12-
- [`Model.findByIdAndDelete()`](/docs/api.html#model_Model.findByIdAndDelete)
13-
- [`Model.findByIdAndRemove()`](/docs/api.html#model_Model.findByIdAndRemove)
14-
- [`Model.findByIdAndUpdate()`](/docs/api.html#model_Model.findByIdAndUpdate)
15-
- [`Model.findOne()`](/docs/api.html#model_Model.findOne)
16-
- [`Model.findOneAndDelete()`](/docs/api.html#model_Model.findOneAndDelete)
17-
- [`Model.findOneAndRemove()`](/docs/api.html#model_Model.findOneAndRemove)
18-
- [`Model.findOneAndReplace()`](/docs/api.html#model_Model.findOneAndReplace)
19-
- [`Model.findOneAndUpdate()`](/docs/api.html#model_Model.findOneAndUpdate)
20-
- [`Model.replaceOne()`](/docs/api.html#model_Model.replaceOne)
21-
- [`Model.updateMany()`](/docs/api.html#model_Model.updateMany)
22-
- [`Model.updateOne()`](/docs/api.html#model_Model.updateOne)
8+
- [`Model.deleteMany()`](/docs/api.html#model_Model-deleteMany)
9+
- [`Model.deleteOne()`](/docs/api.html#model_Model-deleteOne)
10+
- [`Model.find()`](/docs/api.html#model_Model-find)
11+
- [`Model.findById()`](/docs/api.html#model_Model-findById)
12+
- [`Model.findByIdAndDelete()`](/docs/api.html#model_Model-findByIdAndDelete)
13+
- [`Model.findByIdAndRemove()`](/docs/api.html#model_Model-findByIdAndRemove)
14+
- [`Model.findByIdAndUpdate()`](/docs/api.html#model_Model-findByIdAndUpdate)
15+
- [`Model.findOne()`](/docs/api.html#model_Model-findOne)
16+
- [`Model.findOneAndDelete()`](/docs/api.html#model_Model-findOneAndDelete)
17+
- [`Model.findOneAndRemove()`](/docs/api.html#model_Model-findOneAndRemove)
18+
- [`Model.findOneAndReplace()`](/docs/api.html#model_Model-findOneAndReplace)
19+
- [`Model.findOneAndUpdate()`](/docs/api.html#model_Model-findOneAndUpdate)
20+
- [`Model.replaceOne()`](/docs/api.html#model_Model-replaceOne)
21+
- [`Model.updateMany()`](/docs/api.html#model_Model-updateMany)
22+
- [`Model.updateOne()`](/docs/api.html#model_Model-updateOne)
2323

2424
A mongoose query can be executed in one of two ways. First, if you
2525
pass in a `callback` function, Mongoose will execute the query asynchronously
@@ -55,7 +55,7 @@ Mongoose executed the query and passed the results to `callback`. All callbacks
5555
`callback(error, result)`. If an error occurs executing the query, the `error` parameter will contain an error document, and `result`
5656
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.
5757

58-
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.
58+
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.
5959

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

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

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

docs/schematypes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ console.log(new M({ b: 'nay' }).b); // false
467467

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

470-
Mongoose supports arrays of [SchemaTypes](./api.html#schema_Schema.Types)
470+
Mongoose supports arrays of [SchemaTypes](./api.html#schema_Schema-Types)
471471
and arrays of [subdocuments](./subdocs.html). Arrays of SchemaTypes are
472472
also called _primitive arrays_, and arrays of subdocuments are also called
473473
_document arrays_.

0 commit comments

Comments
 (0)