【发布时间】:2018-04-05 14:05:45
【问题描述】:
卡住了 Sequelize findOrCreate 方法。
所以我期待得到tags的空数组,但我得到tag.id, tag.name ...等。
[ { id: 2,
name: 'Inf 1',
email: 'andrew@ww.rt',
createdAt: 2017-10-24T16:30:38.314Z,
updatedAt: 2017-10-24T16:31:02.076Z,
category_id: null,
'tags.id': null, <---- Here is should be just like tags: []`
'tags.name': null,
'tags.description': null,
'tags.createdAt': null,
'tags.updatedAt': null,
'tags.UsersTags.createdAt': null,
'tags.UsersTags.updatedAt': null,
'tags.UsersTags.user_id': null,
'tags.UsersTags.tag_id': null },
false ]
模型使用
User.findOrCreate({
raw: true,
where: query,
defaults: update,
include: [{
model: Model.Tag,
as: 'tags'
}]
})
【问题讨论】:
标签: javascript node.js sequelize.js