Freamee 0 Posted Wednesday at 03:39 PM hello. I want to use command param, to deleteOne from the collection. But _id is '5dcc20c3770b9707143301fb' how can i call those by value? kincsLocations.deleteOne({ _id: value }, function (err, veh) { Share this post Link to post Share on other sites
xshockz 0 Posted Wednesday at 04:21 PM If you're not using mongoosejs (which automatically casts the string into ObjectId) then you'd have to cast the string into an ObjectId. const idToDelete = '5dcc20c3770b9707143301fb' // if not using mongoose collection.deleteOne({_id: new mongodb.ObjectID(idToDelete)}, callback}; // if using mongoose > 4 (deleteOne isn't supported on mongoose 4 or higher) collection.findByIdAndRemove({_id: idToDelete}, callback); references:https://docs.mongodb.com/manual/reference/method/db.collection.deleteOne/https://mongoosejs.com/docs/api.html#model_Model.findByIdAndRemove Share this post Link to post Share on other sites
Freamee 0 Posted Wednesday at 07:24 PM so i can not use these integeres yeah to delete one? Share this post Link to post Share on other sites
xshockz 0 Posted yesterday at 08:35 AM The (1) and (2) are probably just the index of the array. You can't use that. Share this post Link to post Share on other sites