diff options
| author | Adam Soltys <[email protected]> | 2022-11-11 12:28:55 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-11-11 12:28:55 -0800 |
| commit | f997db5936742852dcae363921f54cf9244e45e9 (patch) | |
| tree | c6bcefbdb0ecca6424d4fa320fa1dcc2ebc390d1 | |
| parent | 9b4e84941531ba97c3dc836524d1b84ee75ffcaa (diff) | |
| download | coinos-server-f997db5936742852dcae363921f54cf9244e45e9.tar.gz coinos-server-f997db5936742852dcae363921f54cf9244e45e9.zip | |
order contacts
| -rw-r--r-- | routes/users.js | 6 |
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); |
