You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
794 B

  1. /**
  2. * File schema
  3. */
  4. module.exports = (sequelize, DataTypes) => {
  5. let fileSchema = sequelize.define('file', {
  6. category: {
  7. type: DataTypes.ENUM('binary', 'image'),
  8. allowNull: false,
  9. defaultValue: 'binary'
  10. },
  11. mime: {
  12. type: DataTypes.STRING,
  13. allowNull: false,
  14. defaultValue: 'application/octet-stream'
  15. },
  16. extra: {
  17. type: DataTypes.JSONB,
  18. allowNull: true
  19. },
  20. filename: {
  21. type: DataTypes.STRING,
  22. allowNull: false
  23. },
  24. basename: {
  25. type: DataTypes.STRING,
  26. allowNull: false
  27. },
  28. filesize: {
  29. type: DataTypes.INTEGER,
  30. allowNull: false,
  31. validate: {
  32. isInt: true,
  33. min: 0
  34. }
  35. }
  36. }, {
  37. timestamps: true,
  38. version: true
  39. })
  40. return fileSchema
  41. }