I have a question for this situation with a collection in mongodb
this is my Post collection
{
"_id" : ObjectId("530f67584fb1a510bc18c03f"),
"creatorId" : "5f6f2c26-4101-4eae-90d1-20d109bea925",
"creationDate" : ISODate("0001-01-01T00:00:00Z"),
"category" : 23,
"location" : [
-60.67045855832774,
52.86982649605247
],
"replies" :
[
{
"_id" : ObjectId("531acfc34fb1a50edc86fdcb"),
"creatorId" : "0891f887-a6bc-4183-be10-2653b7b45e79"
},
{
"_id" : ObjectId("531acfc34fb1a50edc86fdcb"),
"creatorId" : "0891f887-a6bc-4183-be10-2653b7h76s22"
}
]
}
I perform a query passing clientId who is watching the page and a polygon for return all posts in polygon area and I want to add a custom fields because I want to know this info :
If Post is mine ( clientId == creatorId)
- If there are replies (replies.count > 0 )
If post is not mine
- If there are one my reply ( there is one of reply with replies.creatorId == clientId)
and i want to do this in only one query because I want to view all list of posts and know what kind of different colour mark the post.
The result that I want is something like this (if is it possible) or something else that returns the infos required.
{
"_id" : ObjectId("530f67584fb1a510bc18c03f"),
"category" : 23,
"location" : [
-60.67045855832774,
52.86982649605247
],
"isMine" : true,
"replies" : 20,
"OneAnswerIsMine": false
}
Thanks Thanks Thanks in advance
L