diff options
| author | Adam Soltys <[email protected]> | 2020-04-24 22:46:45 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-04-24 22:46:45 -0700 |
| commit | 83f973224bad381df62774bcc058f76eab635f0c (patch) | |
| tree | ef231f4490b0c9d194b8683be50c05524738903e /lib/utils.js | |
| parent | 306357c24d3014b55ae1cd25b954a695ea2e5cc6 (diff) | |
| download | coinos-server-assets.tar.gz coinos-server-assets.zip | |
wipassets
Diffstat (limited to 'lib/utils.js')
| -rw-r--r-- | lib/utils.js | 79 |
1 files changed, 53 insertions, 26 deletions
diff --git a/lib/utils.js b/lib/utils.js index 7784ae5c..7b4b1668 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,30 +1,57 @@ const { Op } = require("sequelize"); -module.exports = { - async getUser(username) { - return db.User.findOne({ - include: [ - { - model: db.Payment, - as: "payments", - order: [["id", "DESC"]], - where: { - [Op.or]: { - received: true, - amount: { - [Op.lt]: 0 - } +getUser = async username => { + return db.User.findOne({ + include: [ + { + model: db.Payment, + as: "payments", + order: [["id", "DESC"]], + where: { + [Op.or]: { + received: true, + amount: { + [Op.lt]: 0 } - }, - limit: 12 + } }, - { - model: db.Account, - as: "accounts" - } - ], - where: - { [Op.or]: { username, id: username }} - }); - } -}; + limit: 12 + }, + { + model: db.Account, + as: "accounts" + }, + { + model: db.Account, + as: "account" + } + ], + where: { username }, + }); +} + +getUserById = async id => { + return db.User.findOne({ + include: [ + { + model: db.Payment, + as: "payments", + order: [["id", "DESC"]], + where: { + [Op.or]: { + received: true, + amount: { + [Op.lt]: 0 + } + } + }, + limit: 12 + }, + { + model: db.Account, + as: "accounts" + } + ], + where: { id } + }); +} |
