Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change deprecated findOneAndRemove to findOneAndDelete (mongoose v8 compatibility) #113

Merged
merged 3 commits into from
Feb 29, 2024

Conversation

santiq
Copy link
Contributor

@santiq santiq commented Jan 10, 2024

Fix #112

@dziraf
Copy link
Contributor

dziraf commented Jan 10, 2024

Hi @santiq

Thanks for contributing. There's one more issue that needs to be fixed until we're compatible with v8 and it's changing count to countDocuments when counting the number of records matching given filters:
https://github.com/SoftwareBrothers/adminjs-mongoose/blob/master/src/resource.ts#L71

The problem is that countDocuments usage is a bit different and we need to make sure that it works with the provided filters.

Also, please bump mongoose version in devDependencies and peerDependencies to v8. We can make it a breaking change.

@santiq
Copy link
Contributor Author

santiq commented Jan 24, 2024

@dziraf

According to mongoose documentation

The countDocuments() function is similar to count(), but there are a few operators that countDocuments() does not support.

Below are the operators that count() supports but countDocuments() does not, and the suggested replacement:
$where: $expr
$near: $geoWithin with [$center] (https://www.mongodb.com/docs/manual/reference/operator/query/center/#op._S_center)
$nearSphere: $geoWithin with $centerSphere

It is safe to merge since people would need to upgrade to Mongoose v8 to use this anyway.

@nimeshpokhrel
Copy link

This deprecated method is already breaking many apps which uses mongo v8 so this should be fixed ASAP. Had to manually change findOneAndRemove to findOneAndDelete in node_modules for existing apps to function correctly.

@dziraf dziraf merged commit f99d2ea into SoftwareBrothers:master Feb 29, 2024
github-actions bot pushed a commit that referenced this pull request Feb 29, 2024
Copy link

🎉 This PR is included in version 4.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mongoose version 8 compatibility
3 participants