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.

Alberto De Caro
  • 5,147
  • 9
  • 47
  • 73
Job Smith
  • 263
  • 1
  • 6
  • 15

2 Answers2

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.

JohnnyHK
  • 305,182
  • 66
  • 621
  • 471
  • 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... – Job Smith Jun 12 '12 at 02:57
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)
parkerproject
  • 2,138
  • 1
  • 17
  • 14