3

Mongodb noob questions!

I want to do something similar to rake db:drop but in mongodb, to clear out the contents of my document.

So far I've found the command db.dropDatabase() but is it right that I have to enter it from the mongodb interactive shell? (Any tips on how to enter the shell would be appreciated, I tried following the instructions over at the Mongodb site but I couldn't get it up and running).

Is there a simpler way to do this from the command line?

Edit: I tried typing mongo and the shell popped up lol.

3
  • 3
    According to mongoid.org/docs/rails/rake.html rake db:drop should work in a Mongoid project - are you getting any errors? Commented Apr 16, 2012 at 15:56
  • ah thanks, it did not occur to me to check the mongoid documentation OR actually try rake db:drop - noob mistake! Commented Apr 16, 2012 at 20:51
  • 2
    I also found mongo DB_NAME --eval 'db.dropDatabase();' but your way is obviously much more straightforward. Whoever down voted me I apologize! Hopefully this helps other noobs in my position. Commented Apr 16, 2012 at 20:52

2 Answers 2

8

rake db:mongoid:drop

this will work

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

Comments

0

There is a ton of information on the shell here: http://www.mongodb.org/display/DOCS/Overview+-+The+MongoDB+Interactive+Shell

But to Drop a mongodb its .Drop()

1 Comment

As far as I can tell .Drop() is used more to drop collections. I ended up going to my mongo shell by entering mongo at the command line, show dbs to list all databases, use <dbname> to select the database I wanted to drop and then entering db.dropDatabase().

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.