I'm not sure why this would happen as Im returning only the values of an instance in other locations just fine. See anything wrong with my code?
app.get('/profile', checkAuth, function(req, res) {
var useObj = req.user;
var guilds = req.user.guilds;
User.findAll({
where: { userid: useObj.id },
include: [{
model: Guild
}]
}).then(function(group) {
console.log(group.get({
plain: true
}))
})
});
I'm not sure why this would happen as Im returning only the values of an instance in other locations just fine. See anything wrong with my code?
app.get('/profile', checkAuth, function(req, res) {
var useObj = req.user;
var guilds = req.user.guilds;
User.findAll({
where: { userid: useObj.id },
include: [{
model: Guild
}]
}).then(function(group) {
console.log(group.get({
plain: true
}))
})
});
Share
Improve this question
asked Sep 22, 2016 at 4:54
Mr. BigglesWorthMr. BigglesWorth
1,5403 gold badges19 silver badges33 bronze badges
1 Answer
Reset to default 7The problem is you're trying to call get
function of array, not instance, so, findAll()
always returns an array of instances. Use findOne()
instead or loop result
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745586653a4634580.html
评论列表(0条)