Basically I am searching messages.
I have 2 collections:
Users:
[
{
"_id": "Xuibgsadbgsi35Gsdf",
"fullName": "User A"
},
{
"_id": "Afstg34tg4536gh",
"fullName": "User B"
},
{
"_id": "KHJDFhfs7dfgsvdfwsef",
"fullName": "User C"
}
]
Messages:
[
{
"_id": "YONgsa793423bD",
"groupId": "Phsdfyg92345sgb7651",
"senderId": "Xuibgsadbgsi35Gsdf",
"message": "Hello there!"
},
{
"_id": "sdgDFGbaofh135df",
"groupId": "Phsdfyg92345sgb7651",
"senderId": "KHJDFhfs7dfgsvdfwsef",
"message": "Hello @Xuibgsadbgsi35Gsdf"
},
{
"_id": "sdgDFGbaofh135df",
"groupId": "Phsdfyg92345sgb7651",
"senderId": "KHJDFhfs7dfgsvdfwsef",
"message": "Hello"
}
]
Now here I want to search: User A
, so I should get those message in which User A
is involved in any way, either he is a sender or he is mentioned in some message text.
How can I query this scenario?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…