[英]Can't add new attributes to existing model sails.js
我是sails.js的新手。 我需要在sails js中为现有模型添加字段。 这里是
module.exports = {
attributes: {
id: {
columnName: 'id',
type: 'integer',
autoIncrement: true,
primaryKey: true,
unique: true
},
username: {
columnName: 'username',
type: 'STRING',
required: true,
},
userLevel: {
columnName: 'user_level',
type: 'integer',
required: true,
defaultsTo: 1
},
...
但是只要我在模型js中添加字段就像
newAttribute: {
columnName: 'new_attribute',
type: 'integer',
required: true
}
我收到错误“E_UKNOWN”。 更确切地说,当我尝试使用更新的模型登录时,我收到以下消息:
rr {"data":{"err":{"error":"E_UNKNOWN","status":500,"summary":"Encountered an unexpected error","raw":{"code":"ER_BAD_FIELD_ERROR","errno":1054,"sqlState":"42S22","index":0}}},"status":401,"config":{"method":"POST","transformRequest":[null],"transformResponse":[null],"data":{*email and password here*},"url":"auth/login","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json;charset=utf-8"}},"statusText":"Unauthorized"}
感谢您的帮助。
UPD如果我将NODE_ENV设置为开发,它会工作。 可能是connection.js文件的问题?
似乎我找到了解决问题的方法。 起初我将NODE_ENV设置为开发,我猜,这些表是创建的。 然后我将NODE_ENV更改为生产。 而现在它的工作没有奇怪的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.