I'm having this mongo db query which fetches a conversation thread and it's participant details. Tabs are a part of threads.
var threadObject = await db
.collection("threads")
.findOne({ tabs: { $in: [ObjectId("5f2ad2ed59645244cc6a837a")] } });
Thread schema:
{
"_id": {
"$oid": "5f2ad2bb59645244cc6a8379"
},
"thread_participants": [
{
"$oid": "5f2ad2a759645244cc6a8377"
},
{
"$oid": "5f2ad2a159645244cc6a8375"
}
],
"tabs": [
{
"$oid": "5f2ad2ed59645244cc6a837a"
}
],
"date_created": {
"$date": "2020-08-05T15:39:39.088Z"
}
}
Users schema:
{
"_id": {
"$oid": "5f2ad2a159645244cc6a8375"
},
"name": {
"familyName": "Doe",
"givenName": "John"
},
"email": "johndoe@example.com",
"display_picture": "url",
"threads": [
{
"$oid": "5f2ad2bb59645244cc6a8379"
}
]
},
{
"_id": {
"$oid": "5f2ad2a759645244cc6a8377"
},
"name": {
"familyName": "Doe",
"givenName": "Monica"
},
"email": "monicadoe@example.com",
"display_picture": "url",
"threads": [
{
"$oid": "5f2ad2bb59645244cc6a8379"
}
]
}
Now the thing is I want to retrieve the user's first name and last name along with the result of this threadObject. How do I approach this?