settings.js 696 B

123456789101112131415161718192021222324252627282930313233343536
  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. }, {
  24. classMethods: {
  25. set (values) {
  26. values.id = 1
  27. return Settings.upsert(values)
  28. },
  29. get () {
  30. return Settings.findById(1)
  31. }
  32. }
  33. })
  34. return Settings
  35. }