SoftwareBrothers / adminjs-mongoose

Mongoose adapter for AdminJS
MIT License
14 stars 39 forks source link

Use count or estimatedDocumentCount based on the filters applied #78

Closed imjiten closed 2 years ago

imjiten commented 2 years ago

There is an issue with this change applied here https://github.com/SoftwareBrothers/adminjs-mongoose/pull/75

estimatedDocumentCount always returns the total documents in the collection. It ignores the filers. Ref: https://www.mongodb.com/docs/manual/reference/method/db.collection.estimatedDocumentCount/#behavior

The count method is still valid when you want to get the count of documents for a given filter.

The change made in https://github.com/SoftwareBrothers/adminjs-mongoose/pull/75 is always returning the total documents in the collection no matter what filter is applied.

We need to add a condition to check if the filter exists and use the estimatedDocumentCount accordingly

imjiten commented 2 years ago

cc: @rseibane @dziraf

imjiten commented 2 years ago

@dziraf Created another PR https://github.com/SoftwareBrothers/adminjs-mongoose/pull/80 to fix the linter issue

github-actions[bot] commented 2 years ago

:tada: This PR is included in version 2.0.4 :tada:

The release is available on:

Your semantic-release bot :package::rocket: