diff --git a/mongoose.js b/mongoose.js index 89803f908a11b25da6571faf93ec18c24574a043..781be29e330c276ada9b179bc56f1199a160ad28 100644 --- a/mongoose.js +++ b/mongoose.js @@ -41,4 +41,23 @@ class ChatData { } }) } + + findChat (firstParticipantId, secondParticipantId) { + var participantIds = [ firstParticipantId, secondParticipantId ] + participantIds.sort() + + this.ChatModel.findOne({ participant_ids: participantIds }, function (err, result) { + if (err) { + return console.error(err) + } + + if (result) { + var chats = result.chats + + chats.forEach(function (chat) { + console.log(chat) + }) + } + }) + } }