cleaner icon indicating copy to clipboard operation
cleaner copied to clipboard

Meteor 2.6.1 Issue: [MONGODB DRIVER] Warning: collection.remove is deprecated. Use deleteOne, deleteMany, or bulkWrite instead.

Open DanielDornhardt opened this issue 3 years ago • 3 comments

The Title pretty much describes it.

I get a warning on the server console that says:

[MONGODB DRIVER] Warning: collection.remove is deprecated. Use deleteOne, deleteMany, or bulkWrite instead. I can see that it is triggerd from the xolvio:cleaner package by setting the NODE_OPTIONS="--trace-warnings" environment variable:

image

DanielDornhardt avatar Feb 25 '22 08:02 DanielDornhardt

We're grateful for this package and it's a "classic" in our meteor setup, so we're pretty much used to it just doing what it does! Would be cool if someone could have a look, I don't have the time to investigate this currently.

If it's not possible to fix at all, eventually maybe we can do a fork + MR, but it might take some time.

DanielDornhardt avatar Feb 25 '22 08:02 DanielDornhardt

Looks like just changing the one line at https://github.com/xolvio/cleaner/blob/master/cleaner.js#L25 to var remove = Meteor.wrapAsync(appCollection.deleteMany, appCollection); should do the trick.

Not sure how the package version should change with this? Go up to 0.5.0 or 1.0.0? So that apps possibly using an older version of Meteor and MongoDB would stay on 0.4.0.

jrkinclus avatar Apr 19 '22 14:04 jrkinclus

Thank you @jrkinclus for doing the work to figure that out. I've made a fork with your change, which works for me. The fork also exports the resetDatabase function, since I'm using it as an NPM module.

I'll submit a pull request, but in the meanwhile, feel free to use it if you'd like.

meteor npm install --save git+https://github.com/drone1/xolvio-cleaner

Import like this:

```import { resetDatabase } from 'cleaner'``

drone1 avatar May 11 '22 22:05 drone1