About .Remove... instead?

I got this warning way too many times, .remove is deprecated, at lease wont be removed on the next big update x)

My question is, what do I use instead to fully remove one entry?
My collection has only one document that is updated often, by removing it entirely and placing a new one in its place, I’m using db.collection.remove({}) but I keep getting a warning, tried using deleteOne but didnt experiment much with it… Straight to the point, what can I use to not be warned?

Thanks in advance

Hi @Zoo_Zaa ,

You should use db.collection.deleteOne() or db.collection.deleteMany()

Depands on your intention.

Thanks
Pavel

so I would instead use db.collection.deleteOne({}) to delete that one entry? or must I specify a field for this deleteOne? 'cause its the only entry in the collection…

Its always good to put a filter if you know the criteria…

I hope not to sound lazy, but could you examplify me a working function for removing an entire single present entry(document) in a collection with deleteOne, or deleteMany?

Thank you in advance…

Any base goes, example: 4 fields, one is an array => That’s roughly alike what I have on the .remove warning.

Hi @Zoo_Zaa ,

db.collection.insertOne({item : "pencil"})

db.collection.deleteOne({item : "pencil")

db.collection.insertOne({item : "pencil"})
db.collection.insertOne({item : "pen"})

db.collection.deleteMany({})
//All documents gone