Could I please have your advice and guidance on the how best to achieve the following:
Our system will provide users with access to group of products as public/shared documents via the sync gateway.
The user will then have the ability to update the product docs with their own specific information such as pricing. Thus creating a private version of some documents.
We could like these user specific private version of the documents to be stored via the sync gateway and these to be the version of the documents that have priority for the user over the original publicly share original version of the documents.
How would we best avoid duplicates in this situation where the sync gateway provides the user access to both the publicly shared original version of the document and the user modified private version of certain product documents.
The public document which holds the properties that are public. This document can be read by everyone but not updated (unless you allow some users to update it in the sync function).
The user’s private document. Which holds the properties specific to the user. And only that user can read/write to it.
Then you would have to read from both documents on the client to display the information on the screen. You are not guaranteed that those two documents will be replicated at the same time so there’s a bit more work on the client to determine when both have arrived. But that way you avoid having duplicated properties as you mentioned.
You can give read access to the document to everyone and write access only to a couple of users. But ultimately, the properties that are modified by specific users will be on everyone’s device. If that’s ok in your scenario you could probably do that. And then based on the user privileges, only show the properties of interest (even though the whole document will be in everyone’s database). If that’s not ok you would have to use 2 documents and apply different access rules to each one.