Question

I am using mongojs together with nodejs and express. From so many online documents I only found find() save() update() methods. Is there a delete api ? If so, how to use it?

I am trying to remove one record based on _id which is auto generated by mongdodb...

Any links and examples will be appreciated.

Was it helpful?

Solution

Use the remove method. From a quick look at the source it looks like it's just a passthrough so it likely uses the same parameter conventions as the native node driver, so take a look at those docs.

OTHER TIPS

db.collection.remove(query, [justOne], [callback])

you can read the docs for monogojs https://github.com/mafintosh/mongojs for example To remove a single document from inventory, call the remove() method with the justOne parameter set to true or 1(default). e.g

db.inventory.remove( { type : "food" }, callback)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top