here is my code
(node:10188) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: insert into user
(email
, name
, password
, role
, username
) values ('exam@mail.ru', 'chack', 'password', 'user', 'kkkp') - ER_BAD_FIELD_ERROR: Unknown column 'role' in 'field list'
(node:10188) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
'use strict';
const Model = require('objection').Model;
const AppConstants = require('./../constants');
class user extends Model {
static get tableName() {
return 'user';
}
static get jsonSchema() {
return {
type: 'object',
required: ['username', 'password', 'email', 'name'],
properties: {
id: { type: 'integer' },
username: {type: 'string',
unique: true ,
minlength: AppConstants.USERNAME_MIN_LENGTH,
maxlength: AppConstants.USERNAME_MAX_LENGTH
},
password: {
type: 'string',
minlength: AppConstants.PASSWORD_MIN_LENGTH,
maxlength: AppConstants.PASSWORD_MAX_LENGTH
},
email: { type: 'string',
index: { unique: true },
},
name: { type: 'string'
},
role: { enum: ['admin', 'user'], ///////////// here is
default: 'user'
}
}
};
}
}