I'm trying to create a capped collection with Mongoid. I have a definition as follows:
class Customer
include Mongoid::Document
store_in(collection: 'customers')
field: n, type: String, as: :name
field: a, type: String, as: :address
field: z, type: String, as: :zip
end
I've been referencing the documentation but can't figure out how to make a capped collection in this portion of the code. I've tried removing the store_in
line and replacing it with session.command(create: "customers", capped: true, size: 10000000, max: 1000)
to no avail. Is session
supposed to be replaced with something? Or am I going about this incorrectly?
Mongoid does not provide a mechanism for creating capped collections on the fly - you will need to create these yourself via the Mongo console.