CampbellSoftwareSolutions / mongoose-id-validator

Mongoose plug in to validate ObjectID references point to valid existing documents.
Other
47 stars 26 forks source link

collection.count is deprecated, causes DeprecationWarning #24

Closed idanyadgar closed 6 years ago

idanyadgar commented 6 years ago

As of MongoDB Node.JS driver version 3.1, collection.count is deprecated (http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#count)

This causes a deprecation warning when the validator runs: DeprecationWarning: collection.count is deprecated, and will be removed in a future version. Use collection.countDocuments or collection.estimatedDocumentCount instead

Used here: https://github.com/CampbellSoftwareSolutions/mongoose-id-validator/blob/c0fcb87cadd9a1b15584afbe323c49cbac1a96ee/lib/id-validator.js#L111 And here: https://github.com/CampbellSoftwareSolutions/mongoose-id-validator/blob/c0fcb87cadd9a1b15584afbe323c49cbac1a96ee/lib/id-validator.js#L131

Should change implementation to use collection.countDocuments or collection.estimatedDocumentCount.

kirkle commented 6 years ago

I just made a PR for this change from count() to countDocuments()

martin-css commented 6 years ago

@kirkle, thanks. v0.5.0 now published with this change.