This is my codes. i got result when i was using find() all fields but i want to use find with where condition that produce error. what should i change ??
index : function(req, res, next) {
User.find({}).where({userlevel:{'=' : 'admin'}}).exec(function (err, usernames) {
if (err) {
res.send(400);
} else {
res.view({
usernames : usernames
});
}
},
i want to get all admin usernames from mongoDB..
in html
<% _.each(usernames,function(err,user) { %>
<%= user.usernames %>
<% }) %>
Error :
usernames not defined..
pls help me..I am new to Sails