I am trying to write an aggregation on one of my collections which has a bunch of pointers stored into it.
When I try to build the aggregation using compass, I cant seem to make it work properly.
[
{
'$lookup': {
'from': 'TokenMetaData',
'localField': '_p_token0',
'foreignField': '_id', //with _id I dont get anything back, with objectId I get all the Tokenmetadatas back for each document instead of just the pointer reference document
'as': 'token0'
}
}, {
'$match': {
'_created_at': {
'$gt': new Date('Wed, 20 Apr 2022 18:20:53 GMT')
}
}
}, {
'$group': {
'_id': {
'token0': '$_p_token0.symbol',
'token1': '$_p_token1.symbol'
},
'usd': {
'$sum': '$token0_usd_value'
}
}
}
]