feat: page links table
This commit is contained in:
34
server/models/pageLinks.js
Normal file
34
server/models/pageLinks.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const Model = require('objection').Model
|
||||
|
||||
/**
|
||||
* Users model
|
||||
*/
|
||||
module.exports = class PageLink extends Model {
|
||||
static get tableName() { return 'pageLinks' }
|
||||
|
||||
static get jsonSchema () {
|
||||
return {
|
||||
type: 'object',
|
||||
required: ['path', 'localeCode'],
|
||||
|
||||
properties: {
|
||||
id: {type: 'integer'},
|
||||
path: {type: 'string'},
|
||||
localeCode: {type: 'string'}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static get relationMappings() {
|
||||
return {
|
||||
page: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: require('./pages'),
|
||||
join: {
|
||||
from: 'pageLinks.pageId',
|
||||
to: 'pages.id'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -64,15 +64,11 @@ module.exports = class Page extends Model {
|
||||
}
|
||||
},
|
||||
links: {
|
||||
relation: Model.ManyToManyRelation,
|
||||
modelClass: Page,
|
||||
relation: Model.HasManyRelation,
|
||||
modelClass: require('./pageLinks'),
|
||||
join: {
|
||||
from: 'pages.id',
|
||||
through: {
|
||||
from: 'pageLinks.sourcePageId',
|
||||
to: 'pageLinks.targetPageId'
|
||||
},
|
||||
to: 'pages.id'
|
||||
to: 'pageLinks.pageId'
|
||||
}
|
||||
},
|
||||
author: {
|
||||
|
Reference in New Issue
Block a user