You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current implementation of Garner::Mixins::Mongoid::Document::_latest_by_updated_at currently checks for the existence of the updated_at field. This doesn't cover documents that alias the updated_at field (typically by including include Mongoid::Timestamps::Short). This should consider aliased fields. The latest document query can also be optimized to return a single document. Something along these lines:
defself._latest_by_updated_at# Only find the latest if we can order by :updated_atreturnnilunlessfields['updated_at'] || aliased_fields['updated_at']only(:_id,:_type,:updated_at).order_by(updated_at: :desc).limit(1).firstend
May serve to document the proxied binding behavior on model classes in the readme, so devs know to create indexes on the updated_at field if they so choose.
Cheers!
The text was updated successfully, but these errors were encountered:
onomated
changed the title
Mongoid document proxy_binding doesn't work with aliased updated_at field
Mongoid document proxy binding doesn't work with aliased updated_at field
Jan 3, 2015
The current implementation of
Garner::Mixins::Mongoid::Document::_latest_by_updated_at
currently checks for the existence of theupdated_at
field. This doesn't cover documents that alias theupdated_at
field (typically by includinginclude Mongoid::Timestamps::Short
). This should consider aliased fields. The latest document query can also be optimized to return a single document. Something along these lines:May serve to document the proxied binding behavior on model classes in the readme, so devs know to create indexes on the
updated_at
field if they so choose.Cheers!
The text was updated successfully, but these errors were encountered: