I want to get the count of posts documents using:
db.collection('posts').count()
But, I got a warning:
DeprecationWarning: collection.count is deprecated, and will be removed in a future version. Use collection.countDocuments or collection.estimatedDocumentCount instead
Here is my mongodb nodejs driver version:
"dependencies": {
"mongodb": "^3.1.0"
},
"devDependencies": {
"@types/mongodb": "^3.1.0",
"chai": "^4.1.2",
"mocha": "^5.1.1",
"ts-node": "^7.0.0",
"tslint": "^5.10.0",
"typescript": "^2.9.2"
}
There is no countDocuments
or estimatedDocumentCount
in index.d.ts
file.
How can I solve this warning?