Reputation: 482
I'm quite newbie in sails.js. I need to add fields to an existing model in sails js. Here it is
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
},
...
But as soon as I add the fields in my model js like
newAttribute: {
columnName: 'new_attribute',
type: 'integer',
required: true
}
I get an error "E_UKNOWN". To be more precise, when I try to login with updated model, I get this message:
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"}
Appreciate your help.
UPD It's working if I set NODE_ENV to development. May it could be the problem with connection.js file?
Upvotes: 3
Views: 800
Reputation: 482
Seems that I've found the solution of my problem. At first I set NODE_ENV to development, and, I guess, the tables were created. Then I change NODE_ENV to production. And now it's working without odd errors.
Upvotes: 2