Feature: Support :touch option in relations.
class Person include Mongoid::Document include Mongoid::Timestamps field :name has_one :job, :touch => true end class Job include Mongoid::Document include Mongoid::Timestamps belongs_to :person, :touch => true end
Given I have a person with a job.
Person.work = Jon.new
Saved
Person.save Person.updated_at => 2012-03-07 19:03:15 +0100
When I change person and save it, jon's update_at field is updated too:
person.name = 'Cervantes'
person.save
person.updated_at
=> 2012-03-07 19:05:15 +0100
job.updated_at
=> 2012-03-07 19:05:15 +0100
I would like to use this to do key-based expiration caching. I need to be able to update timestamps in cascade to effectively do that.