I'm trying to dynamically build a query for MongoDB in Node.js. The function that creates it is:
app.set('searchTerm', function (field, str){
var i, searchTerm, keywords;
keywords = str.split(' ');
searchTerm = {field : str , _keywords : keywords};
return searchTerm;
});
My problem is that the object constructed ends up with the string 'field' as a key, not the passed argument. How do I get it to evaluate the argument?