Skip to content
Snippets Groups Projects
Commit 60f0a7db authored by Devin Alvaro's avatar Devin Alvaro
Browse files

Replace var with let and rename mongoose.js to ChatData.js

parent 40ea7415
Branches
No related merge requests found
...@@ -14,10 +14,10 @@ class ChatData { ...@@ -14,10 +14,10 @@ class ChatData {
} }
addChat (senderId, receiverId, content) { addChat (senderId, receiverId, content) {
var participantIds = [ senderId, receiverId ] let participantIds = [ senderId, receiverId ]
participantIds.sort() participantIds.sort()
var chat = { let chat = {
owner_id: senderId, owner_id: senderId,
content: content content: content
} }
...@@ -30,7 +30,7 @@ class ChatData { ...@@ -30,7 +30,7 @@ class ChatData {
} }
if (!done) { if (!done) {
var chat = new this.ChatModel({ let chat = new this.ChatModel({
participant_ids: participantIds, participant_ids: participantIds,
chats: [{ chats: [{
owner_id: senderId, owner_id: senderId,
...@@ -44,7 +44,7 @@ class ChatData { ...@@ -44,7 +44,7 @@ class ChatData {
} }
findChat (firstParticipantId, secondParticipantId) { findChat (firstParticipantId, secondParticipantId) {
var participantIds = [ firstParticipantId, secondParticipantId ] let participantIds = [ firstParticipantId, secondParticipantId ]
participantIds.sort() participantIds.sort()
this.ChatModel.findOne({ participant_ids: participantIds }, function (err, result) { this.ChatModel.findOne({ participant_ids: participantIds }, function (err, result) {
...@@ -53,7 +53,7 @@ class ChatData { ...@@ -53,7 +53,7 @@ class ChatData {
} }
if (result) { if (result) {
var chats = result.chats let chats = result.chats
chats.forEach(function (chat) { chats.forEach(function (chat) {
console.log(chat) console.log(chat)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment