Indices and capped collections with MongoMapper
What is the best way to set up an index or configure a capped collections in a Rails project开发者_开发百科?
From what I've found, it seems that a good way would be to keep this configuration in an initializer.
The command for setting up an index is ModelName.ensure_index :key
, but what is the command for a capped collection?
Just drop down to the ruby driver to create the collection.
http://api.mongodb.org/ruby/1.0.7/Mongo/DB.html#create_collection-instance_method
Foo.database.create_collection(:foo, :capped => true)
Do that in an initializer or something.
精彩评论