feat: save page
This commit is contained in:
@@ -150,16 +150,16 @@ exports.up = knex => {
|
||||
table.integer('authorId').unsigned().references('id').inTable('users')
|
||||
})
|
||||
.table('pages', table => {
|
||||
table.string('editor').references('key').inTable('editors')
|
||||
table.string('locale', 2).references('code').inTable('locales')
|
||||
table.string('editorKey').references('key').inTable('editors')
|
||||
table.string('localeCode', 2).references('code').inTable('locales')
|
||||
table.integer('authorId').unsigned().references('id').inTable('users')
|
||||
})
|
||||
.table('users', table => {
|
||||
table.string('provider').references('key').inTable('authentication').notNullable().defaultTo('local')
|
||||
table.string('locale', 2).references('code').inTable('locales').notNullable().defaultTo('en')
|
||||
table.string('providerKey').references('key').inTable('authentication').notNullable().defaultTo('local')
|
||||
table.string('localeCode', 2).references('code').inTable('locales').notNullable().defaultTo('en')
|
||||
table.string('defaultEditor').references('key').inTable('editors').notNullable().defaultTo('markdown')
|
||||
|
||||
table.unique(['provider', 'email'])
|
||||
table.unique(['providerKey', 'email'])
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -49,11 +49,19 @@ module.exports = class Page extends Model {
|
||||
to: 'users.id'
|
||||
}
|
||||
},
|
||||
editor: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: require('./editors'),
|
||||
join: {
|
||||
from: 'pages.editorKey',
|
||||
to: 'editors.key'
|
||||
}
|
||||
},
|
||||
locale: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: require('./locales'),
|
||||
join: {
|
||||
from: 'users.locale',
|
||||
from: 'pages.localeCode',
|
||||
to: 'locales.code'
|
||||
}
|
||||
}
|
||||
|
@@ -23,13 +23,11 @@ module.exports = class User extends Model {
|
||||
id: {type: 'integer'},
|
||||
email: {type: 'string', format: 'email'},
|
||||
name: {type: 'string', minLength: 1, maxLength: 255},
|
||||
provider: {type: 'string', minLength: 1, maxLength: 255},
|
||||
providerId: {type: 'number'},
|
||||
password: {type: 'string'},
|
||||
role: {type: 'string', enum: ['admin', 'guest', 'user']},
|
||||
tfaIsActive: {type: 'boolean', default: false},
|
||||
tfaSecret: {type: 'string'},
|
||||
locale: {type: 'string'},
|
||||
jobTitle: {type: 'string'},
|
||||
location: {type: 'string'},
|
||||
pictureUrl: {type: 'string'},
|
||||
@@ -52,6 +50,30 @@ module.exports = class User extends Model {
|
||||
},
|
||||
to: 'groups.id'
|
||||
}
|
||||
},
|
||||
provider: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: require('./authentication'),
|
||||
join: {
|
||||
from: 'users.providerKey',
|
||||
to: 'authentication.key'
|
||||
}
|
||||
},
|
||||
defaultEditor: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: require('./editors'),
|
||||
join: {
|
||||
from: 'users.editorKey',
|
||||
to: 'editors.key'
|
||||
}
|
||||
},
|
||||
locale: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: require('./locales'),
|
||||
join: {
|
||||
from: 'users.localeCode',
|
||||
to: 'locales.code'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user