pageLinks.mjs 657 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { Model } from 'objection'
  2. import { Page } from './pages.mjs'
  3. /**
  4. * Users model
  5. */
  6. export class PageLink extends Model {
  7. static get tableName() { return 'pageLinks' }
  8. static get jsonSchema () {
  9. return {
  10. type: 'object',
  11. required: ['path', 'locale'],
  12. properties: {
  13. id: {type: 'integer'},
  14. path: {type: 'string'},
  15. locale: {type: 'string'}
  16. }
  17. }
  18. }
  19. static get relationMappings() {
  20. return {
  21. page: {
  22. relation: Model.BelongsToOneRelation,
  23. modelClass: Page,
  24. join: {
  25. from: 'pageLinks.pageId',
  26. to: 'pages.id'
  27. }
  28. }
  29. }
  30. }
  31. }