I am new to Mongoid and I want to learn more about it. Today I came across
Mongoid::Timestamps
Mongoid::Timestamps
You can read its RubyDoc to find more about Mongoid::Timestamps
. It's nothing special, but in a nutshell:
Including
Mongoid::Timestamps
in your Ruby model classes would tell MongoDB to save timestamps of when a document was created or updated. This creates two new attributes in your model:
- created_at
- updated_at
You use it like this:
class User
include Mongoid::Document
include Mongoid::Timestamps
# Other stuff...
end