ContainerModel.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. const { Sequelize, DataTypes } = require('sequelize');
  2. const sequelize = new Sequelize({
  3. dialect: 'sqlite',
  4. storage: './database/db.sqlite',
  5. logging: false
  6. });
  7. const Containers = sequelize.define('Containers', {
  8. // Model attributes are defined here
  9. id: {
  10. type: DataTypes.INTEGER,
  11. autoIncrement: true,
  12. primaryKey: true
  13. },
  14. name: {
  15. type: DataTypes.STRING,
  16. allowNull: false
  17. },
  18. visibility: {
  19. type: DataTypes.STRING
  20. // allowNull defaults to true
  21. },
  22. size: {
  23. type: DataTypes.STRING
  24. // allowNull defaults to true
  25. },
  26. group: {
  27. type: DataTypes.STRING
  28. // allowNull defaults to true
  29. },
  30. start: {
  31. type: DataTypes.JSON
  32. // allowNull defaults to true
  33. },
  34. stop: {
  35. type: DataTypes.JSON
  36. // allowNull defaults to true
  37. },
  38. pause: {
  39. type: DataTypes.JSON
  40. // allowNull defaults to true
  41. },
  42. restart: {
  43. type: DataTypes.JSON
  44. // allowNull defaults to true
  45. },
  46. remove: {
  47. type: DataTypes.JSON
  48. // allowNull defaults to true
  49. },
  50. logs: {
  51. type: DataTypes.JSON
  52. // allowNull defaults to true
  53. },
  54. update: {
  55. type: DataTypes.JSON
  56. // allowNull defaults to true
  57. },
  58. });
  59. async function syncModel() {
  60. await sequelize.sync();
  61. console.log('Containers model synced');
  62. }
  63. syncModel();
  64. module.exports = Containers;