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',
- },
- name: {
- type: DataTypes.STRING,
- allowNull: false,
- comment: '名',
- },
- img: {
- type: DataTypes.STRING,
- defaultValue: '',
- comment: '头像',
- },
- title: {
- type: DataTypes.STRING,
- comment: '职称',
- },
- desc: {
- type: DataTypes.STRING,
- defaultValue: '',
- comment: '描述',
- },
- phone: {
- type: DataTypes.STRING,
- comment: '手机号',
- },
- type: {
- type: DataTypes.TINYINT,
- defaultValue: 1,
- comment: '1授课2录播',
- },
- },
- {
- comment: '讲师',
- hooks: {
- beforeFind(option) {
- if (!option.order) {
- option.order = [['id', 'desc']];
- }
- },
- },
- }
- );
- module.exports = model;
|