From 9f81288fccdbaf9184d49e61680747945b34f23d Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 17 Jan 2017 11:11:22 +0900 Subject: Fix bug --- src/api/endpoints/messaging/history.js | 5 ++--- src/api/endpoints/messaging/messages.js | 5 ++--- src/api/endpoints/messaging/messages/create.js | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) (limited to 'src/api/endpoints/messaging') diff --git a/src/api/endpoints/messaging/history.js b/src/api/endpoints/messaging/history.js index dafb38fd1a..e6e6ac87b1 100644 --- a/src/api/endpoints/messaging/history.js +++ b/src/api/endpoints/messaging/history.js @@ -34,13 +34,12 @@ module.exports = (params, user) => const history = await History .find({ user_id: user._id - }, {}, { + }, { limit: limit, sort: { updated_at: -1 } - }) - .toArray(); + }); // Serialize res(await Promise.all(history.map(async h => diff --git a/src/api/endpoints/messaging/messages.js b/src/api/endpoints/messaging/messages.js index 12bd13597a..9440e2b3aa 100644 --- a/src/api/endpoints/messaging/messages.js +++ b/src/api/endpoints/messaging/messages.js @@ -90,11 +90,10 @@ module.exports = (params, user) => // Issue query const messages = await Message - .find(query, {}, { + .find(query, { limit: limit, sort: sort - }) - .toArray(); + }); // Serialize res(await Promise.all(messages.map(async message => diff --git a/src/api/endpoints/messaging/messages/create.js b/src/api/endpoints/messaging/messages/create.js index 33634a6140..1cd02cfc58 100644 --- a/src/api/endpoints/messaging/messages/create.js +++ b/src/api/endpoints/messaging/messages/create.js @@ -125,7 +125,7 @@ module.exports = (params, user) => } // 履歴作成(自分) - History.updateOne({ + History.update({ user_id: user._id, partner: recipient._id }, { @@ -138,7 +138,7 @@ module.exports = (params, user) => }); // 履歴作成(相手) - History.updateOne({ + History.update({ user_id: recipient._id, partner: user._id }, { -- cgit v1.2.3-freya