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.

Mar 302011
 

Create an index on a document in MongoDB

Answer:

To create an index on a document in MongoDB, you can enter the shell and execute the statement like:

db.test.ensureIndex({ "fieldName": 1 })

(Assume you need to create index on fieldName of the test collection.)

That's easy?

Oct 092010
 

Drop a database in MongoDB

Answer:

Assuming you are going to drop the `test` database in MongoDB, follow the steps below to drop (delete) it.

>  use test
switched to db test

> db.dropDatabase()
{ "dropped" : "test.$cmd", "ok" : 1 }