diff options
| author | Adam Soltys <[email protected]> | 2020-03-26 10:19:58 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-03-26 10:19:58 -0700 |
| commit | b75a06ea0dadcb7ad2416e900e15276661e065be (patch) | |
| tree | 873b67947303a64acfaa018900b590651331928b | |
| parent | 4eee705620cb0a7626d9d000d4c78c4691784bff (diff) | |
| download | coinos-server-b75a06ea0dadcb7ad2416e900e15276661e065be.tar.gz coinos-server-b75a06ea0dadcb7ad2416e900e15276661e065be.zip | |
filter payments
| -rw-r--r-- | lib/sockets.js | 11 | ||||
| -rw-r--r-- | routes/payments.js | 11 |
2 files changed, 18 insertions, 4 deletions
diff --git a/lib/sockets.js b/lib/sockets.js index d7973a99..f35ca5f5 100644 --- a/lib/sockets.js +++ b/lib/sockets.js @@ -1,6 +1,6 @@ const jwt = require("jsonwebtoken"); const io = require("socket.io"); -const Sequelize = require("sequelize"); +const { Op } = require("sequelize"); /* eslint-disable-next-line */ const pick = (O, ...K) => K.reduce((o, k) => ((o[k] = O[k]), o), {}); @@ -44,8 +44,13 @@ socket.sockets.on("connect", async socket => { model: db.Payment, as: "payments", order: [["id", "DESC"]], - received: { - [Sequelize.Op.ne]: null + where: { + [Op.or]: { + received: true, + amount: { + [Op.lt]: 0, + }, + }, }, limit: 12 } diff --git a/routes/payments.js b/routes/payments.js index 7cb51d02..0e829029 100644 --- a/routes/payments.js +++ b/routes/payments.js @@ -1,5 +1,6 @@ const BitcoinCore = require("bitcoin-core"); const lnd = require("../lib/lnd"); +const { Op } = require("sequelize"); (async () => { bc = new BitcoinCore(config.bitcoin); @@ -37,7 +38,15 @@ const lnd = require("../lib/lnd"); app.get("/payments", auth, async (req, res) => { const payments = await db.Payment.findAll({ - where: { user_id: req.user.id }, + where: { + user_id: req.user.id, + [Op.or]: { + received: true, + amount: { + [Op.lt]: 0, + }, + }, + }, order: [["id", "DESC"]] }); |
