Project field in embedded document within embedded array

后端 未结 2 520
感动是毒
感动是毒 2021-01-21 15:27

I have the following query:

 cursor=self.postCol.aggregate([
      { \"$graphLookup\" : {
        \"from\": \"pCol\",
        \"startWith\": \"$parent\",
                


        
2条回答
  •  遇见更好的自我
    2021-01-21 15:55

    You can replace the else condition with below using $let operator.

     {
        $let: {
            vars: {
                obj: {
                    "$arrayElemAt": ["$parents", 0]
                }
            },
            in: "$$obj.pValue"
        }
     }
    

提交回复
热议问题