1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- 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.INTEGER,
- autoIncrement: true,
- primaryKey: true,
- comment: 'id',
- },
- uid: {
- type: DataTypes.INTEGER,
- allowNull: false,
- comment: '用户id',
- },
- name: {
- type: DataTypes.STRING,
- comment: '名',
- },
- phone: {
- type: DataTypes.STRING,
- comment: '手机号',
- },
- code: {
- type: DataTypes.CHAR(6),
- allowNull: false,
- comment: '邀请码',
- },
- discount: {
- type: DataTypes.DECIMAL(3, 2),
- defaultValue: 1,
- comment: '折扣',
- },
- remark: {
- type: DataTypes.STRING,
- defaultValue: '',
- comment: '备注',
- },
- },
- {
- comment: '推荐人',
- hooks: {
- beforeFind(option) {
- if (!option.order) {
- option.order = [['id', 'desc']];
- }
- },
- },
- }
- );
- module.exports = model;
|