diff options
| author | Adam Soltys <[email protected]> | 2020-04-13 19:59:16 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-04-13 19:59:16 -0700 |
| commit | c8c2b9df1c9f70a95673f436b7f1e14964a6744e (patch) | |
| tree | ddd7a94104f5a21884e57d0f47272ca844e26e8f /lib/utils.js | |
| parent | efc94656d47ee8ca3a83d95a4526e1dbc76a2218 (diff) | |
| download | coinos-server-c8c2b9df1c9f70a95673f436b7f1e14964a6744e.tar.gz coinos-server-c8c2b9df1c9f70a95673f436b7f1e14964a6744e.zip | |
getuser utility function
Diffstat (limited to 'lib/utils.js')
| -rw-r--r-- | lib/utils.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/utils.js b/lib/utils.js new file mode 100644 index 00000000..c6e02a1a --- /dev/null +++ b/lib/utils.js @@ -0,0 +1,29 @@ +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 + } + } + }, + limit: 12 + }, + { + model: db.Account, + as: "accounts" + } + ], + where: { username } + }); + } +}; |
