queryView not working with key parmeter in cordova/phonegap

I have spent hours on this, but can’t figure out a solution.

This is one of my view:

AllAccounts : {
    map : function(doc) {
        if (doc.type === "group") {
            emit(doc.id,doc.id)
        }
    }.toString()
} 

When I use coax library from https://github.com/couchbaselabs/Couchbase-Lite-PhoneGap-Plugin , it works perfectly fine:

config.views([‘AllAccounts’, { key: “351658”} ],function(err,res){
console.log(JSON.stringify(res,null,2))
})
result:

  "offset": 0,
  "total_rows": 5,
  "rows": [
    {
      "doc": null,
      "id": "group_351658",
      "value": "351658",
      "key": "351658"
    }
  ] 

But when I switched to this library that uses $http and I do this:

var params = {  "key" : "351658" , "include_docs" : true }; 
return databse.queryView(config.designDoc,"PartyEventsPending", params); 

I get:

{"offset":0,"total_rows":5,"rows":[]}

I have tried alot of things and in my conclusion since the coax request is like this:

http://0d5f9215-adc7-4098-993a-9a73e036aba4:edeabc2c-1024-459c-bbdc-19480edd7fcb@localhost:5986/todos/_design%2Ftodo10/_view/AllAccounts?key=%22351658%22

and $http request is like this from this library:

http://ad6f4d60-65eb-44bc-a6bd-a6bf3a7f14de:d39661b1-e347-4cf1-a837-1a4520b29915@localhost:5984/todos/_design/todo/_view/AllAccounts?key=351658

This might be causing the problem. I need help asap please.

BTW, without key param, it works perfectly fine:

{
  "offset": 0,
  "total_rows": 5,
  "rows": [
    {
      "doc": null,
      "id": "group_109719",
      "value": "109719",
      "key": "109719"
    },
    {
      "doc": null,
      "id": "group_109719",
      "value": "109775",
      "key": "109775"
    },
    {
      "doc": null,
      "id": "group_109719",
      "value": "111480",
      "key": "111480"
    },
    {
      "doc": null,
      "id": "group_109719",
      "value": "116329",
      "key": "116329"
    },
    {
      "doc": null,
      "id": "group_351658",
      "value": "351658",
      "key": "351658"
    }
  ]
}

Looks like you filed this as an issue on Github and it’s being tracked there. It’s a bug in the JS library you’re using.

yes should I delete this?

We can leave it up in case someone else runs into this issue, so they can find the Github issue.

Potential Ugly Fix:

If I just force quotes around the string param, it works.

var params = { "key" : "\"351658\""}; 
database.queryView(config.designDoc,"AllAccounts", params).then(function(res){
    console.log(JSON.stringify(res,null,2))
});