Re: sync function issue - got 'undefined' when set doc's channel with value that included doc.keys

35 views
Skip to first unread message

Jens Alfke

unread,
May 11, 2015, 4:43:15 PM5/11/15
to mobile-c...@googlegroups.com
Weird — is that your sync function exactly as present in the config file? Because my guess is that there’s a typo in one of the places you put “key_id”, even though that isn’t showing up in the code you posted. Because it’s clear that the variable key_id in the channel(…) call is undefined.

You can call log(…) in a sync function to log a string to the console. That might help you debug this.

—Jens

atom992

unread,
May 13, 2015, 11:57:26 AM5/13/15
to mobile-c...@googlegroups.com
my whole sync function like this:
function(doc,oldDoc){
if(doc.type == "type1"){
    if(doc.key_id1){
        channel('u-' + doc.key_id1);
    }
  }
  if(doc.type == "type2"){
if(doc.key_id){
channel('b-'+doc.key_id);
}
}
}

If I use switch I get right result.
Reply all
Reply to author
Forward
0 new messages