title: How to get all the records in mongodb having object id
body: <p>In the mongodb there is a user data has been stored in collection <code>challange</code> the data seems like bellow:</p>
  
  <pre><code>{
  "_id" : 1,
   "name" : "puneet",
   "last" : "jindal",
   "email" : "puneet@g.com"
  }
  {
   "_id" : ObjectId("5b3af82cdb3aaa47792b5fd3"),
   "name" : "hardeep",
   "last" : "singh",
   "email" : "hardeep@g.com"
  }
  { 
   "_id" : 3,
   "name" : "gaurav",
   "last" : "bansal",
   "email" : "gaurav@g.com"
  }
  {
   "_id" : ObjectId("5b3af87ddb3aaa47792b5fd4"),
   "name" : "manish",
   "last" : "jindal",
   "email" : "manish@g.com"
  }
  </code></pre>
  
  <p>In the above data there are four records and two of them having id in the integer form and other will having id in object form. I just want to retrieve the all the records which are having the <code>object id</code> in the id field. can anyone tell what query should I write in the code that will only retrieve that records which are having the object id.</p>
  
  <p>Updated:</p>
  
  <p>code I'm using :</p>
  
  <pre><code>type User struct {
   Id              bson.ObjectId    `json:"_id" bson:"_id,omitempty"`
   Name            string    `json:"name,omitempty" bson:"name,omitempty"`
   Last            string `json:"last,omitempty" bson:"last,omitempty"`
   Email          string `json:"email,omitempty" bson:"email,omitempty"`
  }
  type Users []User
  
  func GetAllUsers(listQuery interface{}) (result Users, err error) {
   mongoSession := config.ConnectDb()
   sessionCopy := mongoSession.Copy()
   defer sessionCopy.Close()
   getCollection := mongoSession.DB(config.Database).C(config.UsersCollection)
   err = getCollection.Find(listQuery).Select(bson.M{"password": 0}).All(&amp;result)
   if err != nil {
      return result, err
   }
   return result, nil
  }
  
  conditions := bson.M{'_id': bson.M{'$type': "objectId" } }
  data, err := models.GetAllUsers(conditions) 
  </code></pre>
  
  <p>The error I'm facing by using this :-</p>
  
  <blockquote>
    <p>controllers/UserController.go:18:23: invalid character literal (more than one character)
    controllers/UserController.go:18:28: cannot use '\u0000' (type rune) as type string in map key</p>
  </blockquote>