This little task turned out to be harder than I thought.
Consider the following very simple Posts collection. Suppose I want to display all the posts, coupled with only the comments that were not deleted.
I.E. filter out the deleted comments from the comments array.
Since I have 100s of deleted comments per post, is there a way to do this server side?
The collection:
{
"author": {},
"message": "This is post1",
"comments": [
{
"message": "Im number 1!!!",
"state": {
"deleted": false
}
},
{
"message": "YOU MOTHERF****R",
"state": {
"deleted": true
}
},
{
"message": "tHIS IS GREAT!",
"state": {
"deleted": false
}
},
{
"message": "I can type better than you guys",
"state": {
"deleted": false
}
}
]
},
{
"author": {},
"message": "This is post 2",
"comments": [
{
"message": "This is bulls**t",
"state": {
"deleted": true
}
},
{
"message": "YOU MOTHERF****R",
"state": {
"deleted": true
}
},
{
"message": "I hate u!",
"state": {
"deleted": true
}
},
{
"message": "I wanna have your children",
"state": {
"deleted": false
}
}
]
}