I have a very simple mongoose query, that returns correctly but the field display ordering is not consistent. Notice how sometimes it lists _id and then username and sometimes it lists username and then _id. Any way to fix this?
exports.list = function(req, res){
return db.userModel.find({}, 'username', function (err, users) {
if(!err) {
return res.json(users);
} else {
console.log(err);
return res.send(400);
}
});
}
Output
[
{
"username": "admin",
"_id": "5145293a420135521c000001"
},
{
"username": "bob",
"_id": "5145293b420135521c000002"
},
{
"_id": "5145293b420135521c000003",
"username": "example"
}
]