1

I have sub document of array "fan_array" containing id and is_blocked field. I want to check if given id is present in fan_array in aggregation pipeline only.

Sample document

{
"_id" : ObjectId("599edbef4942810edf6ff9ad"),
"name" : "irfan khan",
"email" : "work.irfan99@gmail.com",
"password" : "$2a$10$lJfN4BAxvzag1/6OvR8IuearPjBoaq6PLwNNV9eBZF97dJGnHE1o2",
"username" : "irfan",
"profile_pic" : "irfan.jpg",
"updated_at" : ISODate("2017-08-24T14:00:15.517Z"),
"created_at" : ISODate("2017-08-24T14:00:15.517Z"),
"is_blocked" : 2,
"notification_setting" : [],
"user_type" : 1,
"is_user_active" : 1,
"__v" : 0,
"fan_array" : [ 
    {
        "id" : "599edc7d4942810edf6ff9b4",
        "is_blocked" : 1
    }, 
    {
        "id" : "599edc7d4942810edf6ff9b1",
        "is_blocked" : 2
    }, 
    {
        "id" : "599edc7d4942810edf6ff9b2",
        "is_blocked" : 1
    }
],
"fanLength" : 13

}

Neil Lunn
  • 148,042
  • 36
  • 346
  • 317
Irfan Khan
  • 395
  • 4
  • 14

0 Answers0