- Fixed Image avatar user list, q-qvatar rounded image
This commit is contained in:
@@ -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
|
||||
// });
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user