123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- 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,
- defaultValue: '',
- comment: '问题名称',
- },
- tid: {
- type: DataTypes.INTEGER,
- allowNull: false,
- defaultValue: 0,
- comment: '类型ID',
- },
- content: {
- type: DataTypes.TEXT,
- defaultValue: '',
- comment: '问题内容',
- },
- },
- {
- comment: '常见问题',
- hooks: {
- beforeFind(option) {
- if (!option.order) {
- option.order = [['id', 'ASC']];
- }
- },
- },
- }
- );
- module.exports = model;
|