diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-12 08:46:28 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-12 08:46:28 +0100 |
| commit | aefc83f729ab3f3c35d9371ec972fb6885b13125 (patch) | |
| tree | 526aab55889bc6714c377d53eaa8d9a43fe36001 /bucky/db | |
| parent | 5e053888b7bec0017f191c8b30c405abd085711f (diff) | |
mail qa
Diffstat (limited to 'bucky/db')
| -rw-r--r-- | bucky/db/index.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/bucky/db/index.js b/bucky/db/index.js index c2cf947..8715125 100644 --- a/bucky/db/index.js +++ b/bucky/db/index.js @@ -51,8 +51,7 @@ db.getUser = function(id) { return model.fetch() } db.getUserByUsername = function(username) { - var model = new User({'username': username}) - return model.fetch() + return new User({'username': username}).fetch() } db.getLastlog = function(limit){ return knex.column('username').column('lastseen').select().from('users').orderBy('lastseen', 'desc').limit(limit || 10) @@ -188,12 +187,18 @@ db.destroyKeyword = function(id){ db.getMailboxes = function(username){ return Mailbox.query("where", "owner", "=", username).fetchAll() } +db.getMailbox = function(mbox){ + return new Mailbox({mbox: mbox}).fetch() +} db.getMailboxCounts = function(boxes){ return knex.column('mbox').count('* as count').select().from('messages').where('mbox', 'in', boxes).groupBy('mbox') } db.createMailbox = function(data){ return new db.Mailbox(data).save() } +db.bumpMailboxCount = function(mbox){ + new db.Mailbox({ mbox: mbox }).fetch() +} /* MESSAGES */ @@ -212,6 +217,7 @@ db.getMessages = function(username, box, limit, offset){ db.getMessage = function (id){ var model = new Message({'id': id}) return model.fetch().then(function(message){ + if (! message) return null message.set("body", message.get("body").toString() ) return message }) |
