|
| 1 | +/* eslint-disable key-spacing, no-multi-spaces */ |
| 2 | + |
| 3 | +module.exports = function (DB, { INTEGER, BIGINT, DATE, STRING, ENUM, BOOLEAN, DATEONLY, NOW }) { |
| 4 | + const Model = DB.define('account', |
| 5 | + { |
| 6 | + id: { type: INTEGER, allowNull: false, primaryKey: true, autoIncrement: true }, |
| 7 | + test_param: { type: BIGINT, allowNull: false, defaultValue: 1000 }, |
| 8 | + first_name: { type: STRING, allowNull: true, defaultValue: 'abc', field: 'first-name' }, |
| 9 | + last_name: { type: STRING, allowNull: false, defaultValue: '' }, |
| 10 | + nickname: { type: STRING, allowNull: false, defaultValue: '' }, |
| 11 | + gender: { type: ENUM, allowNull: false, values: ['male', 'female', 'unknown'], defaultValue: 'unknown' }, |
| 12 | + birth_date: { type: DATEONLY, allowNull: true }, |
| 13 | + last_login_dt: { type: DATE, allowNull: true }, |
| 14 | + created_at: { type: DATE, allowNull: true, defaultValue: NOW }, |
| 15 | + email: { type: STRING, allowNull: false }, |
| 16 | + password: { type: STRING, allowNull: false }, |
| 17 | + is_deleted: { type: BOOLEAN, allowNull: false, defaultValue: false }, |
| 18 | + is_blocked: { type: BOOLEAN, allowNull: false, defaultValue: false }, |
| 19 | + // city_id -> city.id |
| 20 | + }, |
| 21 | + { |
| 22 | + timestamps: false, |
| 23 | + underscored: true, |
| 24 | + tableName: 'account' |
| 25 | + } |
| 26 | + ) |
| 27 | + |
| 28 | + Model.associate = (models) => { |
| 29 | + Model.belongsTo(models.city) |
| 30 | + // Model.hasMany(models.team, { foreignKey: { allowNull: false } }) |
| 31 | + } |
| 32 | + |
| 33 | + return Model |
| 34 | +} |
0 commit comments