title: Retrieve item list by checking multiple attribute values in MongoDB in golang
body: <p>This question based on MongoDB,How to retrieve selected items retrieve by selecting multiple condition.It is like IN condition in Mysql </p>
  
  <blockquote>
    <p>SELECT * FROM venuelist WHERE venueid IN (venueid1, venueid2)</p>
  </blockquote>
  
  <p>I have attached json data structure that I have used.<strong><em>[Ref: JSON STRUCTUE OF MONGODB ]</em></strong>.</p>
  
  <p>As an example, it has a venueList then inside the venue list, It has several attribute venue id and sum of user agents name and total count as value.user agents mean user Os,browser and device information. In this case I used os distribution.In that case i was count linux,ubuntu count on particular venueid.</p>
  
  <p>it is like that,</p>
  
  <pre><code>"sum" : [
      {
          "name" : "linux",
          "value" : 12
      },
      {
          "name" : "ubuntu",
          "value" : 4
      }
  ],
  </code></pre>
  
  <p>Finally I want to get count of all linux user count by selecting venueid list in one find query in MongoDB.</p>
  
  <p>As example, I want to select all count of linux users by conditioning if venue id <strong><em>VID1212</em></strong> or <strong><em>VID4343</em></strong></p>
  
  <p><strong>Ref: JSON STRUCTUE OF MONGODB</strong></p>
  
  <pre><code>{
      "_id" : ObjectId("57f940c4932a00aba387b0b0"),
      "tenantID" : 1,
      "date" : "2016-10-09 00:23:56",
      "venueList" : [
          {
              "id" : “VID1212”,
              "sum" : [
                  {
                        "name" : "linux",
                        "value" : 12
                  },
                  {
                      "name" : "ubuntu",
                      "value" : 4
                  }
              ],
              “ssidList” : [    // this is list of ssid’s in venue
                  {
                      "id" : “SSID1212”,
                      "sum" : [
                          {
                              "name" : "linux",
                              "value" : 8
                          },
                          {
                              "name" : "ubuntu",
                              "value" : 6
                          }
                      ],
                      “macList” : [  // this is mac list inside particular ssid  ex: this is mac list inside the SSID1212
                          {
                              "id" : “12:12:12:12:12:12”,
                              "sum" : [
                                  {
                                      "name" : "linux",
                                      "value" : 12
                                  },
                                  {
                                      "name" : "ubuntu",
                                      "value" : 1
                                  }
                              ]
                          }
                      ]
                  }
              ]
          },
          {
              "id" : “VID4343”,
              "sum" : [
                  {
                       "name" : "linux",
                       "value" : 2
                  }
              ],
              "ssidList" : [
                  {
                      "id" : “SSID4343”,
                      "sum" : [
                          {
                              "name" : "linux",
                              "value" : 2
                          }
                      ],
                      "macList" : [
                          {
                              "id" : “43:43:43:43:43:34”,
                              "sum" : [
                                  {
                                      "name" : "linux",
                                      "value" : 2
                                  }
                              ]
                          }
                      ]
                  }
              ]
          }
      ]
  }
  </code></pre>
  
  <p>I am using golang as language to manipulation data with mongoldb using mgo.v2 package</p>
  
  <blockquote>
    <p>expected out put is :</p>
    
    <p>output</p>
    
    <ul>
    <li>linux : 12+2 = 14 </li>
    <li>ubuntu : 4+0 = 4</li>
    </ul>
    
    <p>Don't consider inner list in venuelist.</p>
  </blockquote>