Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-1452

Issue in filtering based on subdocument

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.1.4
    • Component/s: CRUD
    • None
    • Environment:
      Windows

      For the document below

      { "_id":ObjectId("5e00841f03d2a48f209b0905"), "uID":\{"ABC"}

      ,

      "units":[{"locID":"11","size":"small","accessible":true,"enabled":true,"reserved":false,"occupied":false},
      {"locID":"13","size":"medium","accessible":true,"enabled":true,"reserved":false,"occupied":false},
      {"locID":"15","size":"large","accessible":true,"enabled":true,"reserved":false,"occupied":false}]
      }

      when I try to filter based on uID and units.locID I'm getting any documents

      Here is the filter and option

       
      filter: = bson.D{{"$and", bson.A{bson.D{{"uID", "ABC"}, {"units.locID", "11"}}}}}
      opts := options.FindOne().SetProjection(bson.D{

      {"_id", 0}

      , {"units", 1}})
       

      I've tried this which gives back all units

      filter: = bson.D{

      {"uID", "ABC"}

      , {"units.locID", "11"}} 

      I want to get the unit which has  uID = ABC and locID = 11

       

       

            Assignee:
            isabella.siu@mongodb.com Isabella Siu (Inactive)
            Reporter:
            abhaykumar1@gmail.com Abhay Kumar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: