how to delete a record using mongojs

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.

Answers


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.


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)

Need Your Help

Can't do operation with awk command

shell awk

What we have to do if input is variable each time and on the bases of that input we have to again make another operation on that output of first command. please refer below example.

Internationalizaton of HTML Files

javascript jquery html internationalization

I am developing a project and uses HTML files (not JSP or any other technology at client side). I use JQuery for scripting. I have tables, columns, and many fields that have "text" on them. How can I