1
votes

I'm trying to setup a filtered replication in CouchDb:

The filter I use is the following:

function(doc, req){ 

   if(doc._id == req.query.myid){ 
      return true;
   } 

   return false;
}

To test the filter I make this call:

GET /people/_changes?filter=data/mobile&query_params={"myid": "1"}
  • The name of the database is "people"
  • The design document with the filter is "_design/data"
  • And the name of the filter is "mobile"

And I get this as result:

{"results":[

],
"last_seq":126}

when I had to get the document with id equals to "1".

Can anyone tell me where I'm wrong?

2
can you give an example of what your document looks like? - Akshat Jiwan Sharma

2 Answers

1
votes

I think the problem is that you are asking for a filtered list of changes. Since there are none the result set it empty. Replication accepts post requests only. Check out the example in couch db wiki.

{"source":"http://example.org/example-database","target":"http://admin:[email protected]:5984/example-database", "filter":"myddoc/myfilter", "query_params": {"key":"value"}}

1
votes

Try this:

GET /people/_changes?filter=data/mobile&myid="1"

The query_params object contains all params you set via GET. Probably also myid=1 would work, but I'm not quite sure.

Hope this helps!