检查聚合管道中数组的子文档中的值

时间:2017-09-05 10:22:37

标签: node.js mongodb mongoose

我有数组的子文档" fan_array"包含id和is_blocked字段。我想检查给定的id是否仅存在于聚合管道中的fan_array中。

示例文档

{
"_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

}

0 个答案:

没有答案