Skip to content

Instantly share code, notes, and snippets.

@burningTyger
Created December 27, 2011 15:59
Show Gist options
  • Save burningTyger/1524119 to your computer and use it in GitHub Desktop.
Save burningTyger/1524119 to your computer and use it in GitHub Desktop.
Mongomapper remove a collection

You have a collection of objects in you MongoDB like this here:

class Student
  include MongoMapper::Document
  key :name, String, :required => true
  key :firstname, String, :required => true
  key :course, String
end

To clean up your database you can either do this:

Student.all.each { |s| s.destroy }

or, and this is possibly a lot faster:

Student.collection.remove
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment