Garrit Franke
3 years ago
2 changed files with 48 additions and 20 deletions
@ -0,0 +1,34 @@ |
|||||||
|
const { Model } = require("objection"); |
||||||
|
const Knex = require("knex"); |
||||||
|
const knexConfig = require("../knexfile"); |
||||||
|
|
||||||
|
class Redirect extends Model { |
||||||
|
static get tableName() { |
||||||
|
return "redirects"; |
||||||
|
} |
||||||
|
|
||||||
|
static get jsonSchema() { |
||||||
|
return { |
||||||
|
type: "object", |
||||||
|
required: ["forward_to", "alias"], |
||||||
|
properties: { |
||||||
|
id: { type: "integer" }, |
||||||
|
forwardTo: { type: "string" }, |
||||||
|
alias: { type: "string" }, |
||||||
|
}, |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
static get relationMappings() { |
||||||
|
return { |
||||||
|
user: { |
||||||
|
relation: Model.BelongsToOneRelation, |
||||||
|
modelClass: "User", |
||||||
|
from: "redirects.user_id", |
||||||
|
to: "user.id", |
||||||
|
}, |
||||||
|
}; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
module.exports = Redirect; |
Loading…
Reference in new issue