aboutsummaryrefslogtreecommitdiffstats
path: root/lib/utils.js
blob: c6e02a1a34d94a9a34637fe8f25dd0165a6af2bc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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 }
    });
  }
};