admin管理员组文章数量:1022944
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
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
本文标签: javascriptSequelize Calling get(plain true )) returns get is not a functionStack Overflow
版权声明:本文标题:javascript - Sequelize: Calling .get({plain: true })) returns .get is not a function - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745586651a2157635.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论