Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-22881

lookup between local (multiple)array of values and foreign (single) value

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Major Change
    • Sprint:
      Query 11 (03/14/16), Query 12 (04/04/16)

      Description

      Example Order Document:

      {
          _id: ObjectId("..."),
          products: [ ObjectId("..<Car ObjectId>.."), ObjectId("..<Bike ObjectId>..") ]
      }
      

      Not Working Query:

      db.orders.aggregate([ {
          $lookup: {
                 from: "products",
                 localField: "products",    <= array of IDs
                 foreignField: "_id",
                 as: "productObjects"
          }
      } ])
      

      Desired Result

      {
        _id: ObjectId("..."),
        products: [
          ObjectId("..<Car ObjectId>.."),
          ObjectId("..<Bike ObjectId>..")
        ],
        productObjects: [
          {<Car Object>},
          {<Bike Object>}
        ],
      }
      

      source: http://stackoverflow.com/questions/34967482/lookup-on-objectids-in-an-array

        Attachments

          Issue Links

            Activity

              People

              Votes:
              0 Vote for this issue
              Watchers:
              13 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: