function check_model_owner(field, value, callback) {
Model.find({where: {field: value }}, function(err, models) {
//code
});
}
This code is called from two different places, and what follows is the same for both calls.
Of course this breaks now because field
, in the where clause, does actually not exist in the model, and should be substituted by the field
variable from the function parameters....can I do that?
You can create the query object:
function check_model_owner(field, value, callback) {
var query = {};
query[field] = value;
Model.find({where: query}, function(err, models) {
});
}