I am trying to use the value of a variable in a mongo expression as you can see below:
DbModels.prototype.findByParam = function(_collection, param, id, callback) {
this.getCollection(_collection, function(error, sel_collection) {
if( error ) callback(error)
else {
sel_collection.findOne({param.toString(): id}, function(error, result) {
if( error ) callback(error)
else callback(null, result);
});
}
});
};
However, the param.toString() gives an error. Any suggestions how I can use the value of the param variable in the mongoDb expression?
Thanks