Skip to content

Instantly share code, notes, and snippets.

@j13k
Last active April 5, 2019 03:01
Show Gist options
  • Save j13k/ac976dd58b9495ed72b8cb3748ddd905 to your computer and use it in GitHub Desktop.
Save j13k/ac976dd58b9495ed72b8cb3748ddd905 to your computer and use it in GitHub Desktop.
Attempt to do CouchDB filtered replication by view
{
"_id": "_design/groups",
"views": {
"itemsByGroup": {
"map": "function(doc) {\n if (doc.type == 'group') {\n for (var i in doc.itemIds) {\n emit([doc._id, i], {_id: doc.itemIds[i]});\n }\n }\n}"
}
}
}
{
"docs": [
{
"_id": "alice-to-bob",
"source": {
"url": "http://localhost:5984/test-alice",
"headers": {}
},
"target": {
"url": "http://localhost:5984/test-bob",
"headers": {}
},
"filter": "groups/_view/itemsByGroup",
"continuous": true
}
]
}
{
"docs": [
{
"_id": "group#1",
"type": "group",
"itemIds": [
"item#10446",
"item#10483"
]
}
]
}
{
"docs": [
{
"_id": "item#10446",
"type": "item",
"title": "An item"
},
{
"_id": "item#10483",
"type": "item",
"title": "Another item"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment