couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Couchdb Wiki] Update of "Replication" by RobertNewson
Date Mon, 28 Jun 2010 17:23:41 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The "Replication" page has been changed by RobertNewson.
http://wiki.apache.org/couchdb/Replication?action=diff&rev1=19&rev2=20

--------------------------------------------------

  {"source":"http://example.org/example-database","target":"http://admin:password@127.0.0.1:5984/example-database",
"continuous":true, "cancel":true}
  }}}
  
+ === Filtered Replication ===
+ 
+ Sometimes you don't want to transfer all documents from source to target. You can include
one or more filter functions in your design document and then tell the replicator to use them.
+ 
+ A filter function takes two arguments (the document to be replicated and the the replication
request) and returns true or false. If the result is true, then the document is replicated.
+ 
+ {{{
+   function(doc, req) {
+   if (doc.type && doc.type == "foo") {
+     return true;
+   } else {
+     return false;
+   }
+ }
+ }}}
+ 
+ Filters live under the top-level "filters" key;
+ 
+ {{{
+   {
+     "_id":"myddoc",
+     "filters": {
+       "myfilter": "function goes here"
+     }
+   }
+ }}}
+ 
+ Invoke them as follows;
+ 
+ {{{
+ {"source":"http://example.org/example-database","target":"http://admin:password@127.0.0.1:5984/example-database",
"filter":"myfilter"}
+ }}}
+ 
+ You can even pass arguments to them;
+ 
+ {{{
+ {"source":"http://example.org/example-database","target":"http://admin:password@127.0.0.1:5984/example-database",
"filter":"myfilter", "query_params": {"key":"value"}}
+ }}}
  
  See also: 
   * [[Replication_and_conflicts|Replication and conflicts]]

Mime
View raw message