mongoid-history icon indicating copy to clipboard operation
mongoid-history copied to clipboard

Version at

Open malachheb opened this issue 11 years ago • 3 comments

Added the function 'version_at' to get a copy of the object at a given date.

malachheb avatar May 26 '14 16:05 malachheb

Interesting. I'd be down with merging this if we can resolve a few things.

  • I think version_at should take a Time, not a series of numbers.
  • What do you think about calling this just at?
  • Doesn't handle records being deleted. I think if you do a version_at a time after the record has been deleted, it should return nil.
  • Needs more edge case tests (time before, during, after, etc.).
  • You need to update CHANGELOG.

dblock avatar May 27 '14 12:05 dblock

  • ok for Time as parameter, rename the function to at, tests and CHANGELOG.
  • return nil after the record has been deleted is valid only for embeds documents, because at cannot be called from deleted document. Also at should return nil if the time is before the created_at document.

malachheb avatar May 27 '14 15:05 malachheb

Makes sense re: nil.

dblock avatar May 27 '14 17:05 dblock