无法更新sailsjs水线中的布尔值

时间:2016-06-19 18:03:13

标签: sails.js waterline sails-mongo

我正在开发一个基于SailsJS构建的项目,但现在我正在编写文档的更新过程,当我这样做时,会收到以下错误。

   {
      "code": "E_VALIDATION",
      "invalidAttributes": {
      "deleted": [
      {
        "rule": "boolean",
        "message": "\"boolean\" validation rule failed for input: 'true'\nSpecifically, it threw an error.  Details:\n undefined"
      }
    ]}
  }

在模型I中

    deleted: {
        type: 'string',
        boolean: true
    }

在控制器中     //删除指定用户的操作     destroy:function(req,res,next){

    // 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);
    });
}

1 个答案:

答案 0 :(得分:1)

[cust_number,feature1,feature2,feature3,......] 不是Sails.js中的validation rule。您应该使用boolean代替。请参阅list of model attributes

type: 'boolean'模型中:

User