teacher.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. comment: '名',
  22. },
  23. img: {
  24. type: DataTypes.STRING,
  25. defaultValue: '',
  26. comment: '头像',
  27. },
  28. title: {
  29. type: DataTypes.STRING,
  30. comment: '职称',
  31. },
  32. desc: {
  33. type: DataTypes.STRING,
  34. defaultValue: '',
  35. comment: '描述',
  36. },
  37. phone: {
  38. type: DataTypes.STRING,
  39. comment: '手机号',
  40. },
  41. type: {
  42. type: DataTypes.TINYINT,
  43. defaultValue: 1,
  44. comment: '1授课2录播',
  45. },
  46. },
  47. {
  48. comment: '讲师',
  49. hooks: {
  50. beforeFind(option) {
  51. if (!option.order) {
  52. option.order = [['id', 'desc']];
  53. }
  54. },
  55. },
  56. }
  57. );
  58. module.exports = model;