Sails.js,Model.update()抛出ER_BAD_FIELD_ERROR:'where子句'中的未知列'undefined'
我对Sails.js很新
我正在使用MySQL数据库的应用程序。
问题是 :
当我试图更新表(名为' u_others '),Iam得到以下错误:
ER_BAD_FIELD_ERROR:'where子句'中的未知列'undefined':
桌子的结构:
“ 你好 ”
Deatailed:
错误
型号:
“U_others.js”
module.exports = { autoCreatedAt:false, autoUpdatedAt:false, autoPK:false, attributes: { username:{ type:"string", unique:true }, name:{ type:"string", }, d_o_b:{ type: "string" }, phone:{ type: "integer", size: 15 }, gender:{ enum: ['m', 'f', 'other'] }, avatar:{ type: "string" } } };
更新查询
var other = req.param('other_details'); var wheree = { username: username }; var data = { name: other.name, d_o_b: other.d_o_b, phone: other.phone, gender: other.gender, avatar: other.avatar }; U_others.update({username: req.param('username')}, data) .exec(function afterwards(err, updated){ if (err) { return res.negotiate(err); } res.status(201); res.json(updated); });
请求参数主体
{ "username": "xyz", "other_details":{ "name": "xx yy zz", "d_o_b": "2014-11-22", "phone":88787878787, "gender":"m", "avatar":"sdfsdf/sdfsdfsdf/sdfsdf.jpg" } }
请注意:我有console.log()所有req.parameters和所有包含值
删除行autoPK:false
或在您的模型中添加一个属性id
,如下所示。
id:{ type:'integer', primaryKey:true }
或者错误是由于模型中缺less主键id属性
- 如何上传图片文件并使用express nodejs显示
- 契约:在最终确定之前或之后,向经纪公司发布契约
- $ addToSet一个对象到一个数组在mongoose
- Firebase身份validation失败节点JS:NotAuthorizedError
- 有没有一个简单的教程让我思考在Node.js的方式?
- 如何解码nocklogging的响应
- 自定义类与自定义事件和asynchronous工作通过浏览器使用
- 当打包的Electron App在MacOS上运行时,path.resolve(“”)返回根目录(“/”)
- node.js mongodb – collection.find()。toArray(callback)返回空