Do you want to request a feature or report a bug?
Bug.
What is the current behavior?
```
(node:5004) DeprecationWarning: collection.count is deprecated, and will be removed in a future version. Use collection.countDocuments or collection.estimatedDocumentCount instead
````
If the current behavior is a bug, please provide the steps to reproduce.
I am not sure where this comes from, but is probably an internal library that mongoose is using.
What is the expected behavior?
No warning.
Please mention your node.js, mongoose and MongoDB version.
Node: v8.11.3
Mongoose: 5.2.7
MongoDB: 3.6
The underlying mongodb driver has deprecated the .count()
method. You should use .estimatedDocumentCount()
or .countDocuments()
instead.
This isn't fixed, though. This is inherently a problem with what @NewEraCracker pointed out. For example, using findById will reproduce this error in [email protected] with [email protected] and [email protected].
Problem:
node_modules/mongoose/lib/query.js:2086
this._collection.count(conds, options, utils.tick(callback));
Fix:
this._collection.countDocuments(conds, options, utils.tick(callback));
I changed the "this._collection.count (conds, options, utils.tick (callback));"
by "this._collection.collection.countDocuments (conds, options, utils.tick (callback));" and it worked for me.
Most helpful comment
This isn't fixed, though. This is inherently a problem with what @NewEraCracker pointed out. For example, using findById will reproduce this error in [email protected] with [email protected] and [email protected].
Problem:
node_modules/mongoose/lib/query.js:2086
Fix: