1

I'm super excited about CouchDB 3, especially the Partitioned Database feature. I would like to set up something similar to envoy, where you have one database that syncs to many smaller databases.

I was wondering, what's the best way to implement one partition for one user, and only enable users to sync their own partitions. Is it possible to have global changes split into partition changes, using that log for syncing, or is that overthinking on my part?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Mike Zak
  • 105
  • 7
  • I see [no evidence](https://github.com/apache/couchdb-documentation) that this is directly supported. But you can, of course, do filtered replication along the same dimensions as your partitioning. – Jonathan Hall Feb 09 '20 at 15:47
  • Filter replication would be a good start, but if you have many users on one db, then using filter would still need to scan through all users sync log and pickout current user changes. So far the only idea that im having is making my own custom chages log for each user, this is going away from couch db replication and towards a custom one – Mike Zak Feb 14 '20 at 03:34

3 Answers3

1

You can add a selector to the replication document.

"selector": { "_id": { "$regex": "^[PartitionName]:" } }
Dula
  • 1,276
  • 5
  • 14
  • 23
  • Was the use of square brackets (i.e. a character class) in the regex deliberate? Should it read `"^PartitionName:" or does it need to match literal brackets, e.g. `"^\[PartitionName\]:"` ? (possibly double backslashes are needed) – Darren Cook Feb 17 '22 at 19:26
-1

You are right , the brackets expression should be replace by the actual partition name - final expression should be without brackets..

-1

You can add a selector to the replication document.

e.g.

"selector": { "_id": { "$regex": "^CANADA:" } }

or

"selector": { "_id": { "$regex": "^USA:" } }
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103