blocks.mjs 555 B

12345678910111213141516171819202122232425262728
  1. import { Model } from 'objection'
  2. /**
  3. * Block model
  4. */
  5. export class Block extends Model {
  6. static get tableName () { return 'blocks' }
  7. static get jsonAttributes () {
  8. return ['config']
  9. }
  10. static async addBlock (data) {
  11. return WIKI.db.blocks.query().insertAndFetch({
  12. block: data.block,
  13. name: data.name,
  14. description: data.description,
  15. icon: data.icon,
  16. isEnabled: true,
  17. isCustom: true,
  18. config: {}
  19. })
  20. }
  21. static async deleteBlock (id) {
  22. return WIKI.db.blocks.query().deleteById(id)
  23. }
  24. }