problem.js 962 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. tid: {
  25. type: DataTypes.INTEGER,
  26. allowNull: false,
  27. defaultValue: 0,
  28. comment: '类型ID',
  29. },
  30. content: {
  31. type: DataTypes.TEXT,
  32. defaultValue: '',
  33. comment: '问题内容',
  34. },
  35. },
  36. {
  37. comment: '常见问题',
  38. hooks: {
  39. beforeFind(option) {
  40. if (!option.order) {
  41. option.order = [['id', 'ASC']];
  42. }
  43. },
  44. },
  45. }
  46. );
  47. module.exports = model;