I want to access the nested object after an expression. In a usual case, this would be done with "$thing.subthing". I have an expression that will resolve into $thing but I want to access subthing in the same line. My code for this:
[
{"$project":
{
"refAgentId":true,"_id":false
}
},
{
"$lookup":
{
"from":"policyTransactions",
"let":{"refAgentId":"$refAgentId"},
"pipeline":[],
"as":"bind"
}
},
{
"$project":{
"refAgentId":true,
"binding":{
"$arrayElemAt":[{
"$filter":{
"input":"$bind",
"as":"a",
"cond":{
"$eq":[
"$refAgentId",
"$$a.refAgentId"]}}},
0]}
}
}
]
After all that, I would get the result
{
"refAgentId": "d6ae049b-edb6-4e55-b3d3-ae994d02fd02",
"binding": {
"bind": 35,
"refAgentId": "d6ae049b-edb6-4e55-b3d3-ae994d02fd02"
}
}
I want binding to be the 35. I could do this with another project and "binding.bind", but I want to know if it's possible without.