Skip to content

Instantly share code, notes, and snippets.

@madpink
Created August 26, 2017 13:47
Show Gist options
  • Save madpink/29b7239286739748af40e272e45b121a to your computer and use it in GitHub Desktop.
Save madpink/29b7239286739748af40e272e45b121a to your computer and use it in GitHub Desktop.
CouchDB Filter/Selector examples
//FILTER DOCUMENT
{
"_id":"_design/myfilterdoc",
"filters": {
"myfilter": "function(doc, req){if (doc.filterme != 'a'){return false;} return true;}"
}
}
//FILTERED REPLICATION
{
"source": "http://127.0.0.1:5984/repfilter",
"target": "http://127.0.0.1:5984/repfiltertest",
"create_target": true,
"continuous": true,
"filter":"myfilterdoc/myfilter"
}
//SELECTOR REPLICATION (COUCHDB 2.1)
{
"source": "http://127.0.0.1:5984/repfilter",
"target": "http://127.0.0.1:5984/repselectortest",
"create_target": true,
"continuous": true,
"selector": {"filterme":{"$eq":"a"}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment