David Renz
David Renz

Reputation: 375

Versioning documents in MongoDB

I want to add versioning to my documents in my MongoDB. Are there any best practices for versioning in MongoDB? And what's the simplestway to versioning documents in my MongoDB?

Upvotes: 12

Views: 9003

Answers (1)

MuthuKumar Haridoss
MuthuKumar Haridoss

Reputation: 171

You could try the approach specified in the document versioning pattern, before you choose this approach make sure that the use case matches the criteria specified i.e. The Document Versioning Pattern makes a few assumptions about the data in the database and the data access patterns that the application makes.

  1. Each document doesn’t have too many revisions.
  2. There aren’t too many documents to version.
  3. Most of the queries performed are done on the most current version of the document.

If you find that these assumptions don’t fit your use case, this pattern may not be a great fit. You may have to alter how you implement your version of the Document Versioning Pattern or your use case may simply require a different solution.

Upvotes: 2

Related Questions