3

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.

2 Answers 2

9

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I am trying to remove one record based on _id which is auto generated by mongdodb...it seems i need to do something extra in order to make it work...
1
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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.