Return array value in spatial view couchbase 3.0


#1

Hello,

I have this kind of document :
{
“loc”: [
45.3400745,
5.6058141
],
“var1”: “70”,
“var2”: “jjdjdjdjdj”
}

My spatial view:
function (doc,meta) {
if (doc.loc && doc.libelle && doc.enseigne && doc.categorie) {
emit(
{
type: “Point”,
coordinates: [doc.loc[0], doc.loc[1]],
},[doc.var1,doc.var2]);
}
}

Result:
{“total_rows”:0,“rows”:[
{“id”:“2014100413443481”,“key”:[[45.3400745,45.3400745],[5.6058141,5.6058141]],“value”:"[“70”,“jjdjdjdjdj”]",“geometry”:{“type”:“Point”,“coordinates”:[45.3400745,5.6058141]}}
]
}

In couchbase I don’t have any problem.
In 3.0 couchbase don’t return an array but a string.

How can I do ?

Best regards


#2

Hi,

that’s a bug 1. The fix sadly didn’t make it into the 3.0.0 release, but it is fixed already. It will be included in a future release.

The value is double encoded JSON. So a workaround would be that you do a JSON decode in your application code.


#3

Hi,

Thanks a lot. I will try that.