db.T_Forum_Thread.find({ "ThreadReply.ReplyContent" : /范甘迪/ }, { "ThreadReply.$" : 1, "ThreadContent" : 1 })

 

重点在于返回字段:ThreadReply.$:1

 

如果内嵌的数组有多个符合条件只返回了1条,,,待继续深究

 

db.test.aggregate(
    {"$unwind":"$favorite_shards"}, 
    {"$match":
        {"favorite_shards.sid": 
            {"$in": [NumberLong(578), NumberLong(577)]}
        }
    }, 
    {"$group":
         {"_id": "$_id", "favorite_shards":
            {'$push': "$favorite_shards"}
        }
    })     


db.web_mem_favorites.aggregate( {"$project":{"favorite_shards":"$favorite_shards"}}, {"$unwind":"$favorite_shards"}, {"$match":{"favorite_shards.sid": NumberLong(577)}} )

 



相关文章:

  • 2022-02-23
  • 2022-12-23
  • 2021-12-17
  • 2022-12-23
  • 2021-10-25
  • 2021-06-25
  • 2022-02-12
  • 2021-12-01
猜你喜欢
  • 2021-07-17
  • 2022-12-23
  • 2021-09-08
  • 2021-09-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案