Created
August 26, 2017 13:47
-
-
Save madpink/29b7239286739748af40e272e45b121a to your computer and use it in GitHub Desktop.
CouchDB Filter/Selector examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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