Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jul 212011

Update an existing document in MongoDB


In an given collection, if you want to perform update on an existing document, the easiest way is to use the following commands.

employee = db.employees.findOne( { name : "Peter" } );
employee.position = "Project Manager"; employee );


Apr 072011

Drop a collection in MongoDB


To drop a collection in MongoDB, enter the interactive shell, and type:

If you want to remove all the objects only, not dropping the collection, try