2weekmail/api/db/models/Domain.js
2025-03-19 19:56:57 -05:00

51 lines
1.3 KiB
JavaScript

const BaseModel = require('./BaseModel');
const { Model } = require('objection');
class Domain extends BaseModel {
static get tableName() {
return 'domain';
}
static get idColumn() {
return 'domain';
}
static get jsonSchema() {
return {
type: 'object',
required: ['domain', 'description'],
properties: {
domain: { type: 'string', minLength: 1, maxLength: 255 },
description: { type: 'string', maxLength: 255 },
aliases: { type: 'integer', default: 0 },
mailboxes: { type: 'integer', default: 0 },
maxquota: { type: 'integer', default: 0 },
quota: { type: 'integer', default: 0 },
transport: { type: 'string', maxLength: 255 },
backupmx: { type: 'integer', default: 0 },
created: { type: 'string', format: 'date-time' },
modified: { type: 'string', format: 'date-time' },
active: { type: 'integer', default: 1 },
password_expiry: { type: 'integer', default: 0 }
}
};
}
static get relationMappings() {
const Mailbox = require('./Mailbox');
return {
mailboxes: {
relation: Model.HasManyRelation,
modelClass: Mailbox,
join: {
from: 'domain.domain',
to: 'mailbox.domain'
}
}
};
}
}
module.exports = Domain;