I have this Couchdb view that doesn't do what I expect. It does not add code , balance and session to params :
function(doc) { var params = doc.initial_url_params;
On the other hand, this other implementation does the trick:
function(doc) { var params = {}; params["code"] = doc.code; params["balance"] = doc.balance; params["session"] = doc.session.session_id; for (prop in doc.initial_url_params) { params[prop] = doc.initial_url_params[prop]; } emit(doc.code, params); }
Can someone tell me why these two implementations are not equivalent? Am I doing something stupid with Javascript or is it some specific limitation of the implementation of Couchdb Javascript?
For clarity. Here is a json doc example:
{ "_id": "207112eaaad136dca7b0b7b1c6356dc4", "_rev": "3-e02de1f2f269642df98ab19ee023569b", "session_loaded": true, "balance": 20.48, "code": "05428", "initial_url_params": { "page_id": "212" }, "session": { "session_id": "207112eaaad136dca7b0b7b1c6356dc4", "init": true } }
source share