RavenDB Revision management on application level

Viewed 105

Unfortunately this is a very general question...

Imagine an authoring application to create e.g. electric schematics. Engineers draw schematics until they are satisfied with their product and it's ready for production.

At this point a "Revision" would be initiated (say Revision "#1") . From now on all data/documents of this revision can't be changed anymore. It's read-only.

As time goes by, the engineers have smart ideas and start to update the existing schematics based on Revision #1. They add new features, remove features, replace some components with newer versions etc. until they have a Revision #2.

A common requirement this then: What has changed between Rev.1 and 2? Some delta reports are needed.

What would/could that mean with RavenDB?

  1. If the engineers start a new revision, would that mean to copy all documents and insert them with a new Id like "/proj-1/rev-2/component-1000"? How would I update my relations between documents then? Adjust all relations "manually"?

  2. Snapshot the DB? Can I compare a snapshot DB with the current DB?

  3. How would I find all the delta between those revisions?
  4. If I do not copy all documents or snapshot them, would I need to book-keep all changes in separate documents (event-log style) i.e. DocX has been deleted, DocY has been updated with Value1, DocZ has been added etc?
  5. I know that RavenDb has its own revision system. It's based on single changes of a document. Could this be used for advantage here?

Any hints how to model such a system would be highly appreciated.

1 Answers

RavenDB has the notion of revisions for documents, which create read only snapshot of the document. They are created whenever you modify the document.

For your needs, I would recommend creating: plans/1238-A as the document itself. Whenever you need to stamp a read-only revision, use: plans/1238-A/revisions/1 or something like that.

I would recommend not modifying any references, point to the same location, but when reading the revision, ask the referenced revision.

Related