From 02fde0e300ac96a4a88421bf6913f1eb2b605c41 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Tue, 22 Jan 2019 15:26:50 -0800 Subject: [PATCH] Getting mailbox table --- bin/iredmail.js | 4 +++- postgres/models/mailbox.js | 13 +++++++++---- src/modules/iredmail/controller.js | 3 ++- test/a03-iredmail.spec.js | 1 - 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/bin/iredmail.js b/bin/iredmail.js index ccca338..4a1567a 100644 --- a/bin/iredmail.js +++ b/bin/iredmail.js @@ -10,6 +10,7 @@ const config = require('../config') // Models const UsedQuota = require('../postgres/models/used-quota') +const Mailbox = require('../postgres/models/mailbox') class IRedMail { constructor () { @@ -18,7 +19,8 @@ class IRedMail { // Load the models this.models = { - usedQuota: new UsedQuota(this.sequelize) + usedQuota: new UsedQuota(this.sequelize), + mailbox: new Mailbox(this.sequelize) } } diff --git a/postgres/models/mailbox.js b/postgres/models/mailbox.js index 1453b4a..a5f4e9d 100644 --- a/postgres/models/mailbox.js +++ b/postgres/models/mailbox.js @@ -61,13 +61,18 @@ class Mailbox { created: Sequelize.DATE, modified: Sequelize.DATE, expired: Sequelize.DATE, - active: Sequelize.INTEGER, - bytes: Sequelize.BIGINT, - messages: Sequelize.BIGINT + active: Sequelize.INTEGER }, { - timestamps: false + 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: 'mailbox' } + ) } } diff --git a/src/modules/iredmail/controller.js b/src/modules/iredmail/controller.js index 9948b1c..4e89008 100644 --- a/src/modules/iredmail/controller.js +++ b/src/modules/iredmail/controller.js @@ -15,7 +15,8 @@ async function getUsers (ctx) { // console.log(`ctx.iRedMail: ${util.inspect(ctx.iRedMail)}`) // 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 data = await model.findAll() diff --git a/test/a03-iredmail.spec.js b/test/a03-iredmail.spec.js index bee1dd3..a578fa4 100644 --- a/test/a03-iredmail.spec.js +++ b/test/a03-iredmail.spec.js @@ -15,7 +15,6 @@ const LOCALHOST = 'http://localhost:5000' describe('#iRedMail', () => { let testType = 'unit' - let iRedMail before(async () => { // Detect integration test flag.