I am trying to write a query as follows:
ecg = Ecg.create(:collection, options: { timestamp: Time.now,, voltage:
-1.3, metadata: { user_id: 1}})
My Ecg model is as follows:
class Ecg
include Mongoid::Document
include Mongoid::Timestamps
field :voltage, type: Float
field :timestamp, type: Time
belongs_to :user
store_in collection_options: {
time_series: {
timeField: "timestamp",
metaField: "metadata",
granularity: "milliseconds"
}
}
end
The error is vague to me it says the pattern does not match.
The error is as follows: message: Invalid options passed to Ecg.store_in: {:collection_options=>{:time_series=>{:timeField=>"timestamp", :metaField=>"metadata", :granularity=>"milliseconds"}}}. summary: The :store_in macro takes only a hash of parameters with the keys :database, :collection, or :client. resolution: Change the options passed to store_in to match the documented API, and ensure all keys in the options hash are symbols.
Example: class Band include Mongoid::Document store_in collection: 'artists', database: 'music' end
The API for working with timeseries collections was added to Mongoid in 8.1.0 (MONGOID-5370).
If you're using an older version of Mongoid this error would likely be raised. Can you verify you're using at least 8.1.0?