2weekmail/api/db/models/Alias.js
2025-03-22 02:50:26 +00:00

47 lines
1.1 KiB
JavaScript

const BaseModel = require('./BaseModel');
const { Model } = require('objection');
class Alias extends BaseModel {
static get tableName() {
return 'alias';
}
static get idColumn() {
return 'id';
}
static get jsonSchema() {
return {
type: 'object',
required: ['address', 'goto', 'domain'],
properties: {
id: { type: 'integer' },
address: { type: 'string', minLength: 1, maxLength: 255 },
goto: { type: 'string', minLength: 1 },
domain: { type: 'string', minLength: 1, maxLength: 255 },
created: { type: 'string', format: 'date-time' },
modified: { type: 'string', format: 'date-time' },
active: { type: 'integer', default: 1 },
ignore: { type: 'integer', default: 0 }
}
};
}
static get relationMappings() {
const Domain = require('./Domain');
return {
domainRelation: {
relation: Model.BelongsToOneRelation,
modelClass: Domain,
join: {
from: 'alias.domain',
to: 'domain.domain'
}
}
};
}
}
module.exports = Alias;