I have two documents (Party, Ledger) referencing via party_id like below.
Party {
party_id: 1001
party_title: ‘abc’
}
Ledger {
vocno, 1
date: 12-02-2022
transactions: [
{
party_id: 1001
debit;: 1000
credit: null
},
{
party_id: 1002
debit;: null
credit: 1000
}
]
}
I want to query using aggregation framework using $lookup to get results like this.
{
vocno,
date,
transactions: [
{
party_id: 1001,
party_title: ‘abc’,
debit;: 1000,
credit: null
},
{
party_id: 1002,
party_title: ‘xyz’,
debit;: null,
credit: 1000
}
]
how to write query using $lookup