Reputation: 1412
I have some couchdb queries, for which I'm using the jquery-couchdb plugin. I'd like to compile a set of queries with which I can decide at call-time what options to set. E.g.
$db.view("design/view", {
success: function(data) {
// do something e.g.:
callback_function(data);
},
option1: value1,
option2: value2
// What if I want an option3 to be set only some of the time?
});
Is there a way to achieve this? Something like running over kwargs in python, or a way to pass in an object with keys and values?
Cheers, Matt
Upvotes: 0
Views: 82
Reputation: 39950
Like this?
var params = {};
params.success = function(data) {
// do something e.g.:
callback_function(data);
};
if (setOpt1) params.option1 = value1;
if (setOpt2) params.option2 = value2;
$db.view("design/view", params);
Upvotes: 1