Step 2: Creating page Messages: userlist last messages + a page for all the messages received and sent.

This commit is contained in:
Paolo Arena
2019-10-27 00:37:10 +02:00
parent e6c4053ccf
commit 5307c04151
9 changed files with 106 additions and 60 deletions

View File

@@ -32,6 +32,12 @@ const sendmsgSchema = new Schema({
datemsg: {
type: Date,
},
status: {
type: Number,
},
options: {
type: Number,
},
read: {
type: Boolean,
default: false
@@ -53,7 +59,7 @@ sendmsgSchema.statics.findAllMsgByUsernameIdAndIdApp = function (username, lastd
{ idapp }
]
}).then((arrmsg) => {
console.log('arrmsg', arrmsg);
console.log('arrmsg', arrmsg.length);
return arrmsg
}).catch((err) => {
console.error('err', err);
@@ -88,8 +94,12 @@ sendmsgSchema.statics.findLastGroupByUserIdAndIdApp = function (userId, username
},
])
.then((arrmsg) => {
console.table(arrmsg);
return arrmsg
// Remove duplicate
// Exclude my chat
const myarr = arrmsg.filter((ris) => ris._id !== username);
console.table(myarr);
return myarr
}).catch((err) => {
console.error(err);
});