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.

44 lines
808 B

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