Document Versioning

  1. Does the process which reads Change Stream have to be running consciously or it can have downtime? Is there the concept of “resume from” when I start reading from ChangeStream again? What are the provisions for consistency in this?

  2. I was also thinking about implementing versioning in my application itself with the below approach.

Below operations would be in the transaction

Insert for the document (newDocument) comes in with PrimaryKey = PolicytId

  • Get the CurrentVersion from the database using PolicyId
  • Assign the Version number of the newDocument as CurrentVersion + 1
  • Delete existing document and insert newDocument in collection
  • Also insert newDocument in history_collection or archive_collection

What do you think about this approach?