我正在使用sequelize版本4.8.0。根据文档http://docs.sequelizejs.com/class/lib/model.js~Model.html#static-method-update,这看起来应该是正确的,但是,我收到此错误: }
});
tvSTART.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar mcurrentTime = Calendar.getInstance();
int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
int minute = mcurrentTime.get(Calendar.MINUTE);
TimePickerDialog mTimePicker;
mTimePicker = new TimePickerDialog(SetAlarmActivity.this, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
tvSTART.setText( selectedHour + ":" + selectedMinute);
tv_START = ( selectedHour + ":" + selectedMinute);
DateFormat format = new SimpleDateFormat("h:mm", Locale.ENGLISH);
try {
Date date = format.parse(tv_START);
} catch (ParseException e) {
e.printStackTrace();
}
}
}, hour, minute, true);//Yes 24 hour time
mTimePicker.setTitle("Select Start Time");
mTimePicker.show();
}
});
Missing where attribute in the options parameter
日志记录const role = req.body;
sequelize.transaction((t)=> {
return sequelize.models.role.update(role, {where: req.params, transaction:t}).then(() => {
res.json({success: true});
})
})
.catch(errorCatch(res));
}
表明它是:req.params
所以问题并非如此。
任何人都可以告诉我我做错了什么。我认为这可能与交易有关。
答案 0 :(得分:0)
我将这个端点设为GraphQL变种,它的工作方式基本相同。我也将我的续集改为3.30.2,但我不知道它与突变工作有什么关系,因为我也尝试了端点。
const UpdateRole = {
type: ResponsePayload,
args: baseUpdate,
resolve: (root, role, context) => {
return joiValidate({
permission: "WriteRole",
obj: role,
joiModel: roleJoiModel,
user: context.user
}).then(() => {
return sequelize.transaction(t => {
return sequelize.models.role
.update(role, { where: { id: role.id } }, { transaction: t })
.then(() => {
return sequelize.models.role.findOne({ where: { id: role.id } });
})
.then(r => {
return Promise.all([
r.setPermissions(role.permissions || [], { transaction: t }),
r.setUsers(role.users || [], { transaction: t })
]);
})
.then(r => {
if (role.isDefault) {
return sequelize.models.role
.update(
{ isDefault: false },
{
where: {
id: {
$ne: role.id
}
}
}
)
.then(() => {
return Promise.resolve({ success: true });
});
} else {
return Promise.resolve({ success: true });
}
});
});
});