Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-1543

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

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Major - P3 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", }

      ] } ] }

            Assignee:
            kelsey.schubert@mongodb.com Kelsey Schubert
            Reporter:
            senthild4u@gmail.com Senthilkumar Dhanapal
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: