diff --git a/mongoose.js b/ChatData.js similarity index 86% rename from mongoose.js rename to ChatData.js index 1cc5d036724197c5627e88eb9c4e620a4b03b6f5..0930038c7ca2ffcd38c9e9d551217e7fd4b7496f 100644 --- a/mongoose.js +++ b/ChatData.js @@ -14,10 +14,10 @@ class ChatData { } addChat (senderId, receiverId, content) { - var participantIds = [ senderId, receiverId ] + let participantIds = [ senderId, receiverId ] participantIds.sort() - var chat = { + let chat = { owner_id: senderId, content: content } @@ -30,7 +30,7 @@ class ChatData { } if (!done) { - var chat = new this.ChatModel({ + let chat = new this.ChatModel({ participant_ids: participantIds, chats: [{ owner_id: senderId, @@ -44,7 +44,7 @@ class ChatData { } findChat (firstParticipantId, secondParticipantId) { - var participantIds = [ firstParticipantId, secondParticipantId ] + let participantIds = [ firstParticipantId, secondParticipantId ] participantIds.sort() this.ChatModel.findOne({ participant_ids: participantIds }, function (err, result) { @@ -53,7 +53,7 @@ class ChatData { } if (result) { - var chats = result.chats + let chats = result.chats chats.forEach(function (chat) { console.log(chat)