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

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

    • Major Change
    • Query 11 (03/14/16), Query 12 (04/04/16)

      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

            Assignee:
            charlie.swanson@mongodb.com Charlie Swanson
            Reporter:
            joseaio Jose Antonio Illescas Olmo
            Votes:
            0 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: