GraphQL使用Sequelize更新返回null .
updatePerson: {
type: Person,
args: {
value: {
type: UpdatePersonInputType
},
where: {
type: WhereUpdatePersonInputType
}
},
resolve(_, args) {
return Db.models.persons.update( args.value, {
where: args.where
});
}
},
这里我的请求使用GraphiQL
mutation {
updatePerson(value: {firstName: "John", lastName: "Doe", email: "johndoe@example.com"}, where: {id: 1}){
id
firstName
lastName
email
}
}
这就是结果
{
"data": {
"updatePerson": {
"id": null,
"firstName": null,
"lastName": null,
"email": null
}
}
}
也许我使用Sequelize更新会犯错误 . 谁能解释会发生什么?
1 回答
我的坏,我正在使用 MySQL , Sequelize 只需支持 PostgreSQL 如果你需要返回
affectedRows
,但是如果你使用 MySQL 你只能返回affectedCount
.http://docs.sequelizejs.com/en/latest/api/model/#updatevalues-options-promisearrayaffectedcount-affectedrows