From 7d5a9b5a8f82fc4b6c2849dfb5b7f27a2b54a912 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 2 Nov 2022 19:58:00 -0700 Subject: set with_id --- routes/users.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'routes') diff --git a/routes/users.js b/routes/users.js index da8dfca0..b142eb3a 100644 --- a/routes/users.js +++ b/routes/users.js @@ -57,7 +57,7 @@ app.get("/users/:username", async (req, res) => { const { username } = req.params; const user = await db.User.findOne({ - attributes: ["username", "banner", "profile", "address"], + attributes: ["username", "banner", "profile", "address", "currency"], where: Sequelize.where( Sequelize.fn("lower", Sequelize.col("username")), username.toLowerCase() -- cgit v1.2.3 From da2a1713b13b31310843136eeaabe524c4eee42c Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 3 Nov 2022 01:28:29 -0700 Subject: with relation --- db/index.js | 5 +++++ routes/payments.js | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'routes') diff --git a/db/index.js b/db/index.js index 8c94a4d3..81c0fe46 100644 --- a/db/index.js +++ b/db/index.js @@ -124,6 +124,11 @@ Payment.belongsTo(Payment, { foreignKey: "fee_payment_id" }); +Payment.belongsTo(User, { + as: "with", + foreignKey: "with_id" +}); + db.Order = Order; export default db; diff --git a/routes/payments.js b/routes/payments.js index 678b646c..999cba36 100644 --- a/routes/payments.js +++ b/routes/payments.js @@ -125,6 +125,11 @@ app.get("/payments", auth, async (req, res) => { model: db.Account, as: "account" }, + include: { + attrs: ["username", "profile"], + model: db.User, + as: "with" + }, limit, offset }); -- cgit v1.2.3