1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- const { DataTypes } = require('sequelize');
- const connect = require('./connect');
- /*
- type: DataTypes.STRING,
- allowNull: false,
- defaultValue:'',
- comment: '名',
- */
- const model = connect.define(
- __filename.slice(__dirname.length + 1).replace('.js', ''),
- {
- id: {
- type: DataTypes.BIGINT,
- autoIncrement: true,
- primaryKey: true,
- field: 'user_id',
- comment: 'id',
- },
- login: {
- type: DataTypes.STRING(30),
- allowNull: false,
- field: 'user_name',
- defaultValue: '',
- comment: '名',
- },
- phoneNumber: {
- type: DataTypes.STRING(11),
- field: 'phonenumber',
- comment: '头像',
- },
- userType: {
- type: DataTypes.STRING(2),
- field: 'user_type',
- comment: '交易类型(00买家 01卖家 02两者都是)',
- },
- },
- {
- comment: '用户',
- timestamps: false,
- hooks: {
- beforeFind(option) {
- if (!option.order) {
- option.order = [['id', 'desc']];
- }
- },
- },
- }
- );
- module.exports = model;
|