Can I use function parameter as field in a mongo query ?
Example:
var x = function( field , value ){
return Collection.find( { field: value } );
}
the ‘value’ parameter it s working in the query but the ‘field’ parameter it isnt.
Can I use function parameter as field in a mongo query ?
Example:
var x = function( field , value ){
return Collection.find( { field: value } );
}
the ‘value’ parameter it s working in the query but the ‘field’ parameter it isnt.
var x = function( field , value ){
var selector = {};
selector[field] = value;
return Collection.find(selector);
}