How to use $elemMatch on aggregate's projection?

前端 未结 7 1966
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-01 15:27

This is my object:

{ \"_id\" : ObjectId(\"53fdcb6796cb9b9aa86f05b9\"), \"list\" : [ \"a\", \"b\" ], \"complist\" : [ { \"a\" : \"a\", \"b\" : \"b\" }, { \"a\         


        
7条回答
  •  隐瞒了意图╮
    2021-01-01 16:13

    The answer to this question maybe help.

    db.collection_name.aggregate({
        "$match": {
            "complist": {
                "$elemMatch": {
                    "a": "a"
                }
            }
        }
    });
    

提交回复
热议问题