As you can see from the code, I'm returning all users by querying with an undefined variable if param isn't defined. Is this acceptable to do this, or is there some drawback I'm not seeing?
get: function(param, callback){
var query;
if (param) {
query = {username: param}
}
User.find(query, (err, result) => {
if (err) {
callback(err, null);
return;
}
callback(null, result);
});
}
via Michael James
No comments:
Post a Comment