settings.js 773 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. module.exports = (sequelize, DataTypes) => {
  2. let Settings = sequelize.define('Settings', {
  3. forumName: {
  4. type: DataTypes.STRING,
  5. validate: {
  6. isString (val) {
  7. if(typeof val !== 'string') {
  8. throw new sequelize.ValidationError('The name must be a string')
  9. }
  10. }
  11. }
  12. },
  13. forumDescription: {
  14. type: DataTypes.STRING,
  15. validate: {
  16. isString (val) {
  17. if(typeof val !== 'string') {
  18. throw new sequelize.ValidationError('The description must be a string')
  19. }
  20. }
  21. }
  22. },
  23. showDescription: {
  24. type: DataTypes.BOOLEAN,
  25. defaultValue: false
  26. }
  27. }, {
  28. classMethods: {
  29. set (values) {
  30. values.id = 1
  31. return Settings.upsert(values)
  32. },
  33. get () {
  34. return Settings.findById(1)
  35. }
  36. }
  37. })
  38. return Settings
  39. }