Best model for both shared and individual data?

35 views
Skip to first unread message

Mark

unread,
Mar 6, 2016, 12:12:21 PM3/6/16
to mobile-c...@googlegroups.com
I’m starting work on a project that has a need for company provided content with user supplied “attached” content. An analog to this project would be:

My recipes
1. There is a master recipe database that is published and replicated from the company’s Couch* database. It has the recipe and related tags on a single document (myrecipe). Alternately, we may separate the recipe and tags into separate docs.
2. The user can then add their own tags that are not necessarily shared with the company or community, they are their own tags per document.
3. Potential feature but not in v1: The user can replicate tags among their copies of the program using the company’s replication server (using some variation of the “each user has their own database” solution).

I’m torn on how to do the user tags. I see two options:
Option 1: User tags are stored in the main CBL database in separate documents (userTag with a “relationship” to the myrecipe document). For feature #3, build a filtered push replication for the userTag documents.
Option 2: Build a separate CBL database for the userTag documents. This makes replication easier, but marrying the tags between the user and company provided data seems difficult. I don’t see any version of SQLlite’s “ATTACH” functionality in CBL’s documentation (and I’m not sure it even makes sense).

Any suggestions on the right path?

Thanks!

Jens Alfke

unread,
Mar 7, 2016, 11:45:15 AM3/7/16
to mobile-c...@googlegroups.com

On Mar 6, 2016, at 9:12 AM, Mark <mark...@gmail.com> wrote:

3. Potential feature but not in v1: The user can replicate tags among their copies of the program using the company’s replication server (using some variation of the “each user has their own database” solution).

This is pretty easy to do with Sync Gateway without using multiple databases: add the username as a property to each tag document to identify who it belongs to, then route those documents to per-user channels so they’re visible only to the user who created them.

Option 1: User tags are stored in the main CBL database in separate documents (userTag with a “relationship” to the myrecipe document). For feature #3, build a filtered push replication for the userTag documents.

This is the way to go (regardless of server type.) The queries are much easier to work with, and it’s simple to set up a push filter to screen out those documents if you want to keep them local.

—Jens

Mark

unread,
Mar 7, 2016, 1:42:37 PM3/7/16
to mobile-c...@googlegroups.com

> On Mar 7, 2016, at 8:45 AM, Jens Alfke <je...@couchbase.com> wrote:
>
>> Option 1: User tags are stored in the main CBL database in separate documents (userTag with a “relationship” to the myrecipe document). For feature #3, build a filtered push replication for the userTag documents.
>
> This is the way to go (regardless of server type.) The queries are much easier to work with, and it’s simple to set up a push filter to screen out those documents if you want to keep them local.
>

Thanks Jens: That’s the solution I was leaning towards, just thought I’d check my work before I sank significant time into it.

Cheers!
Reply all
Reply to author
Forward
0 new messages