You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
52
52
53
53
```
54
54
collection.update is deprecated. Use updateOne, updateMany, or bulkWrite
* 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.
176
176
* 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).
177
177
* 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.
178
178
@@ -300,7 +300,7 @@ Animal.on('index', error => {
300
300
});
301
301
```
302
302
303
-
See also the [Model#ensureIndexes](./api.html#model_Model.ensureIndexes) method.
303
+
See also the [Model#ensureIndexes](./api.html#model_Model-ensureIndexes) method.
Copy file name to clipboardExpand all lines: docs/migrating_to_5.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -465,7 +465,7 @@ In Mongoose 5.x, the above code will correctly overwrite `'baseball'` with `{ $n
465
465
</a></h3>
466
466
467
467
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).
Copy file name to clipboardExpand all lines: docs/models.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,7 +75,7 @@ const Tank = connection.model('Tank', yourSchema);
75
75
76
76
### Querying
77
77
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.
_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)
113
113
instead._
114
114
115
115
### Change Streams
@@ -156,7 +156,7 @@ You can read more about [change streams in mongoose in this blog post](http://th
156
156
157
157
### Yet more
158
158
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).
A mongoose query can be executed in one of two ways. First, if you
25
25
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
55
55
`callback(error, result)`. If an error occurs executing the query, the `error` parameter will contain an error document, and `result`
56
56
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.
57
57
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.
59
59
60
60
Now let's look at what happens when no `callback` is passed:
61
61
@@ -212,7 +212,7 @@ However, just because you can use `aggregate()` doesn't mean you should.
212
212
In general, you should use queries where possible, and only use `aggregate()`
213
213
when you absolutely need to.
214
214
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)
216
216
aggregation results. Aggregation results are always POJOs, not Mongoose
0 commit comments