aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-11-11 12:28:55 -0800
committerAdam Soltys <[email protected]>2022-11-11 12:28:55 -0800
commitf997db5936742852dcae363921f54cf9244e45e9 (patch)
treec6bcefbdb0ecca6424d4fa320fa1dcc2ebc390d1
parent9b4e84941531ba97c3dc836524d1b84ee75ffcaa (diff)
downloadcoinos-server-f997db5936742852dcae363921f54cf9244e45e9.tar.gz
coinos-server-f997db5936742852dcae363921f54cf9244e45e9.zip
order contacts
-rw-r--r--routes/users.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/routes/users.js b/routes/users.js
index c3ceb35e..319a39c4 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -673,12 +673,12 @@ app.get("/contacts", auth, async function(req, res) {
model: db.User,
as: "with"
},
- attributes: ["id"],
+ attributes: ["createdAt"],
group: ["with_id"],
- order: [[{ model: db.User, as: "with" }, "username", "ASC"]]
+ order: [['createdAt'], [{ model: db.User, as: "with" }, "username", "ASC"]]
});
- res.send(contacts.map(c => c.with));
+ res.send(contacts.map(c => ({ ...c.with.get({ plain: true }), last: c.createdAt })));
} catch (e) {
console.log(e);
res.code(500).send(e.message);