无法更新 sailsjs 水线中的布尔值
Unable to update boolean value in sailsjs waterline
我正在开发一个基于 SailsJS 的项目,但现在我正在为文档编写更新过程,当我这样做时,出现以下错误。
{
"code": "E_VALIDATION",
"invalidAttributes": {
"deleted": [
{
"rule": "boolean",
"message": "\"boolean\" validation rule failed for input: 'true'\nSpecifically, it threw an error. Details:\n undefined"
}
]}
}
在我的模型中
deleted: {
type: 'string',
boolean: true
}
在控制器中
// 删除指定用户的动作
销毁:函数(请求,资源,下一个){
// Logs actions details
sails.log.info("Attempting to delete user ( " , req.param('id') , " ) from IP (IP adddress: " , req.ip , ")" );
User.update({
id: req.param('id')
}, {
deleted: true
}).exec(function (err, user) {
if (err) {
// Handles the response containing some error
ErrorHandler.response(err, req, res, next);
}
res.json(user);
});
}
boolean
不是 validation rule in Sails.js. You should use type: 'boolean'
instead. See list of model attributes。
在您的 User
模型中:
deleted: {
type: 'boolean'
}
我正在开发一个基于 SailsJS 的项目,但现在我正在为文档编写更新过程,当我这样做时,出现以下错误。
{
"code": "E_VALIDATION",
"invalidAttributes": {
"deleted": [
{
"rule": "boolean",
"message": "\"boolean\" validation rule failed for input: 'true'\nSpecifically, it threw an error. Details:\n undefined"
}
]}
}
在我的模型中
deleted: {
type: 'string',
boolean: true
}
在控制器中 // 删除指定用户的动作 销毁:函数(请求,资源,下一个){
// Logs actions details
sails.log.info("Attempting to delete user ( " , req.param('id') , " ) from IP (IP adddress: " , req.ip , ")" );
User.update({
id: req.param('id')
}, {
deleted: true
}).exec(function (err, user) {
if (err) {
// Handles the response containing some error
ErrorHandler.response(err, req, res, next);
}
res.json(user);
});
}
boolean
不是 validation rule in Sails.js. You should use type: 'boolean'
instead. See list of model attributes。
在您的 User
模型中:
deleted: {
type: 'boolean'
}