problem_type.js 740 B

12345678910111213141516171819202122232425262728293031323334353637
  1. const { DataTypes } = require('sequelize');
  2. const connect = require('./connect');
  3. /*
  4. type: DataTypes.STRING,
  5. allowNull: false,
  6. defaultValue:'',
  7. comment: '名',
  8. */
  9. const model = connect.define(
  10. __filename.slice(__dirname.length + 1).replace('.js', ''),
  11. {
  12. id: {
  13. type: DataTypes.INTEGER,
  14. autoIncrement: true,
  15. primaryKey: true,
  16. comment: 'id',
  17. },
  18. name: {
  19. type: DataTypes.STRING,
  20. allowNull: false,
  21. defaultValue: '',
  22. comment: '类型名称',
  23. },
  24. },
  25. {
  26. comment: '常见问题类型',
  27. hooks: {
  28. beforeFind(option) {
  29. if (!option.order) {
  30. option.order = [['id', 'ASC']];
  31. }
  32. },
  33. },
  34. }
  35. );
  36. module.exports = model;