Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

TouchDB iOS Filtered replication based on parameter array doesn't work for me as I don't get any documents coming over to my device #239

Closed
spDream opened this Issue · 2 comments

2 participants

@spDream

TouchDB iOS Filtered replication based on parameter array doesn't work for me as I don't get any documents coming over to my device.

The replication process logs 0 for processed and total documents.

I Setup the CouchReplication to Pull data from BigCouch as follows:

NSMutableDictionary *paramDict = [[NSMutableDictionary alloc] init];
//feedIdList contain the list of _id values for which I need to filter the documents
[paramDict setObject:feedIdList forKey:@"ids"];

NSURL *remoteURL = [NSURL URLWithString:DBUrl];
pullObj = [self.database pullFromDatabaseAtURL:remoteURL];

[pullObj setFilter:@"default/byFeedId"];
[pullObj setFilterParams:paramDict];

[pullObj addObserver:self forKeyPath:@"completed" options:0 context:NULL];
[pullObj addObserver:self forKeyPath:@"running" options:0 context:NULL];

Have setup the View and Filter in the CouchDB as follows:

{
"_id": "_design/default",
"views": {
"byDatabaseName": {
"map": "function(doc) {if(doc.databaseName) emit(doc._id,doc);}"
}
},
"filters": {
"byFeedId": "function(doc,req) {for (var i = 0; i < req.query.ids.length; i++) { if(doc._id == req.query.ids[i]) {return true;}}return false;}"
}
}

Could you please verify and tell me, where I am doing wrong?

@snej
Owner

I'm not certain whether CouchDB filter parameter values are allowed to be arbitrary JSON types or only strings. The examples in the CouchDB wiki only show strings.

@snej snej referenced this issue from a commit
@snej snej Push replicator now encodes non-string filter params as JSON.
I'm not sure whether such parameters are allowed, but JSON encoding seems like the reasonable
way to send them to the remote _changes feed (as opposed to calling ObjC -description on them,
which the code used to do...)
Potential fix for issue #239.
78a2ad7
@snej
Owner

Please see if the above commit fixes your problem. If so, that confirms that CouchDB does support JSON filter parameters. If so, close the bug or otherwise let me know it's working.

@snej snej closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.