On Thursday, October 2, 2014 10:12:00 AM UTC-7, Seung Chan Lim wrote:
>
> I think you're the only one who knows how to answer this. Would love your 
> help.
>
> (This is off of the other thread titled "J. Chris Anderson can you help? 
> Re: filtering changes feed")
>
> --------
>
> Hi, I'm just getting around this. (went on a vacation)
>
> So I see that now a dummy filter function that returns true works great. 
>
> I'm still having trouble making my filter function work, and I'm guessing 
> it has to do with the remark you made about decodeURIComponent and 
> JSON.parse.
>
> I tried throw JSON.stringify(req) as you suggested, but I'm not seeing it 
> show up anywhere. Where does it show up? I have my safari developer console 
> open which I use to debug my phonegap app.
>
>
Sorry about the delay. I just (duh) realized that the JS interpreter that 
runs the filters is not the WebView JS instance, so it won't have access to 
the console. Something might show up in the native log console...

Debugging from inside a sandbox is never fun. One approach to try to divine 
what's going on in there could be to test one piece of logic at a time. eg:

function(doc, req) {
 return !!req.query;
}

if all the docs come through you know "req" has a "query" property.

function(doc, req) {
  return !!req.query.doc_ids;
}

then you know it has a doc_ids property.

function(doc, req) {
  try {
JSON.parse(req.query.doc_ids)
return true
  } catch {
return false
  }
}

now you know if the decodeURIComponent is required or if the execution 
environment is handling it for you.

Etc.

Welcome to debugging a ship in a bottle. :)


 

> Since I call it like this
>
> http://lite.couchbase./status32/_changes?feed=
> continuous&include_docs=true&filter=utils/by_id&doc_ids=%4B%22id%22%5D
>
> And my filter function looks like this
>
> function(doc, req) { 
>    if (req.query.doc_ids.indexOf(doc._id) != -1) { 
>
>        return true;
>    } else {
>        return false;
>
>    } 
>        }
>
> Are you saying I should:
>
> var doc_ids = JSON.parse(decodeURIComponent(requ.query.doc_ids));
> if (doc_ids.indexOf(doc._id) != -1)  {
>
> return true;
> }
>
> Am I understanding you?
>
> slim
>

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/5961ed10-10cd-407b-b439-4ce7241c760f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to