aboutsummaryrefslogtreecommitdiffstats
path: root/lib/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils.js')
-rw-r--r--lib/utils.js29
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 }
+ });
+ }
+};