-
Type: Question
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:Windows
0
down vote
favorite
I have a document which has bills and payments as array. now I need to pull a invoices with its corresponding payments. I tried using $lookup but I failed.
here is the document :
{ "_id" : "123456", "accounts" : [ { "info" :
{ "accountNo" : "123456", }, "bills" : [
{ "invoiceNumber" : "20160909", "billDate" : ISODate("2016-10-20T00:00:00.000Z"), "billAmountDue" : "$100.00", },
{ "invoiceNumber" : "20161020", "billDate" : ISODate("2016-08-20T00:00:00.000Z"), "billAmountDue" : "$10000.00", }], "payments" : [
{ "transactionId" : "20160909", "confirmationId" : "20160909", "invoiceNumber" : "20160909", "paymentMode" : "CreditCard", "paymentSource" : "online", },
{ "transactionId" : "20161020", "confirmationId" : "20161020", "invoiceNumber" : "20161020", "paymentMode" : "CreditCard", "paymentSource" : "online", }] } ] }
I want the result as
{ "_id" : "123456", "accounts" : [ { "info" :
{ "accountNo" : "123456", }, "bills" : [
{ "invoiceNumber" : "20160909", "billDate" : ISODate("2016-10-20T00:00:00.000Z"), "billAmountDue" : "$100.00", }], "payments" : [
{ "transactionId" : "20160909", "confirmationId" : "20160909", "invoiceNumber" : "20160909", "paymentMode" : "CreditCard", "paymentSource" : "online", }] } ] }