9

It doesn't appear to be built-in to Meteor but is there an accepted way to track changes to a record/document? I can think of a number of ways to do this but am curious how others have accomplished this.

An example would be someone's location, if you wanted to track changes for a set period of time.

Thanks!

Wilson Sheldon
  • 255
  • 4
  • 18
  • 3
    What does the canonical `Collection.find(query).observeChanges()` not do that you want it to do? See http://docs.meteor.com/#observe_changes – Andrew Mao Jul 12 '13 at 17:43
  • So what if you wanted to see last 5 changes, for example. Would you observeChanges(), then add changes to another object, perhaps MyObject_history or similar. This probably my relational database mindset but curious what the ideal Meteor way would be. – Wilson Sheldon Jul 12 '13 at 21:45
  • 3
    So are you trying to track revisions to a document? If so, I don't think this is a meteor question; see http://stackoverflow.com/questions/3507624/mongodb-nosql-keeping-document-change-history and http://stackoverflow.com/questions/4185105/ways-to-implement-data-versioning-in-mongodb – Andrew Mao Jul 13 '13 at 00:37
  • Thanks Andrew! Nice to know there wasn't something already in Meteor that I was missing. In my case, I'll make a new 'changes' document for each document and give it the same ID. – Wilson Sheldon Jul 13 '13 at 01:43

1 Answers1

1

I haven't tested this package yet but it seems to track revisions and give the ability to restore older versions. I'm going to test it out now.

https://github.com/todda00/meteor-collection-revisions

Update: I can confirm that this package works in Meteor 1.3. It makes a complete copy of the document of the edited Meteor collection and stores it as an array within the document under "revisions". You can then restore any previous version using the revisionId later on.

phocks
  • 2,933
  • 5
  • 27
  • 28
  • 1
    Note that todda00's repo of meteor-collection-revisions is no longer maintained. Try the following fork instead: https://github.com/nicklozon/meteor-collection-revisions Overall, it seems like a good implementation and reasonably stable by now. – nhe Aug 08 '17 at 17:57