- Fixed Image avatar user list, q-qvatar rounded image

This commit is contained in:
Paolo Arena
2019-10-25 19:08:38 +02:00
parent c8c4f57d16
commit 4154605fdd
6 changed files with 56 additions and 40 deletions

View File

@@ -44,43 +44,54 @@ const sendmsgSchema = new Schema({
sendmsgSchema.statics.findAllByUserIdAndIdApp = function (userId, username, idapp) {
const SendMsg = this;
// Filter my msg
//
// (userId or dest.username === username) and idapp
console.log('userId', userId);
return SendMsg.find({
$and: [
$and: [
{
$or: [
{ 'origin.userId': userId },
{ 'dest.username': username }]
},
{ idapp }
]
}, (err, arrmsg) => {
return arrmsg
});
};
sendmsgSchema.statics.findLastGroupByUserIdAndIdApp = function (userId, username, idapp) {
const SendMsg = this;
return SendMsg.aggregate([
{
$match: {
$or: [{ 'origin.userId': userId }, { 'dest.username': username }, { idapp }],
$and: [{ idapp }]
}
},
{
$group:
{
$or: [
{ 'origin.userId': userId },
{ 'dest.username': username }]
},
{ idapp }
]
}, (err, arrmsg) => {
// console.log('ris arrmsg:', arrmsg);
_id: "$dest.username",
message: { $last: "$message" },
datemsg: { $last: "$datemsg" },
dest: { $last: "$dest" },
origin: { $last: "$origin" },
read: { $last: "$read" }
}
},
{
$sort: { datemsg: -1 }
},
])
.then((arrmsg) => {
console.table(arrmsg);
return arrmsg
}).catch((err) => {
console.error(err);
});
// return SendMsg.find(
// {
// $and: [
// {
// $or: [
// { 'dest.username': username },
// { userId: userId }
// ],
// },
// {
// idapp
// }
// ]
// }, (err, arrmsg) => {
// console.log('ris arrmsg:', arrmsg);
// return arrmsg
// });
};