got forwardings table

This commit is contained in:
Chris Troutner
2019-01-22 16:43:59 -08:00
parent 02fde0e300
commit 49002dc105
3 changed files with 47 additions and 2 deletions
+3 -1
View File
@@ -11,6 +11,7 @@ const config = require('../config')
// Models // Models
const UsedQuota = require('../postgres/models/used-quota') const UsedQuota = require('../postgres/models/used-quota')
const Mailbox = require('../postgres/models/mailbox') const Mailbox = require('../postgres/models/mailbox')
const Forwardings = require('../postgres/models/forwardings')
class IRedMail { class IRedMail {
constructor () { constructor () {
@@ -20,7 +21,8 @@ class IRedMail {
// Load the models // Load the models
this.models = { this.models = {
usedQuota: new UsedQuota(this.sequelize), usedQuota: new UsedQuota(this.sequelize),
mailbox: new Mailbox(this.sequelize) mailbox: new Mailbox(this.sequelize),
forwardings: new Forwardings(this.sequelize)
} }
} }
+42
View File
@@ -0,0 +1,42 @@
/*
Forwardings table in the iRedMail postgres database.
The constructor cxpects an instantiation of the sequalize class. Returns a
Sequelize model.
*/
'use strict'
const Sequelize = require('sequelize')
class Forwardings {
// Expects an instantiation of the sequalize class. Returns a Sequelize model.
constructor (sequelize) {
return sequelize.define(
'forwardings',
{
id: { type: Sequelize.INTEGER, primaryKey: true },
address: Sequelize.STRING,
forwarding: Sequelize.STRING,
domain: Sequelize.STRING,
dest_domain: Sequelize.STRING,
is_maillist: Sequelize.INTEGER,
is_list: Sequelize.INTEGER,
is_forwarding: Sequelize.INTEGER,
is_alias: Sequelize.INTEGER,
active: Sequelize.INTEGER
},
{
timestamps: false,
// disable the modification of tablenames; By default, sequelize will automatically
// transform all passed model names (first parameter of define) into plural.
// if you don't want that, set the following
freezeTableName: true,
// define the table's name
tableName: 'forwardings'
}
)
}
}
module.exports = Forwardings
+2 -1
View File
@@ -16,7 +16,8 @@ async function getUsers (ctx) {
// Sync the model. // Sync the model.
// const model = await ctx.iRedMail.models.usedQuota.sync() // const model = await ctx.iRedMail.models.usedQuota.sync()
const model = await ctx.iRedMail.models.mailbox.sync() // const model = await ctx.iRedMail.models.mailbox.sync()
const model = await ctx.iRedMail.models.forwardings.sync()
const data = await model.findAll() const data = await model.findAll()