title: How to retrieve []bson.M type of map
body: <p>How to retrieve multidimensional []bson.M type of map </p>
  
  <p>The data in mongo is like</p>
  
  <pre><code>"taskData" : { 
      "createdOn" : ISODate("2016-02-20T21:23:11.903Z"), 
      "Task_content" : "@bob", 
      "Priority" : "2", 
      "owner_Uname" : "alice"
  }
  </code></pre>
  
  <p>The code through which i tried to access it </p>
  
  <pre><code>var n []bson.M
   e := collection.Find(bson.M{"users."+strconv.Itoa(j)+".user_name" :   r.FormValue("value[userName]")}).Select(bson.M{"taskData.owner_Uname":1,"_id":0}).All(&amp;n)
  if e != nil {
     fmt.Println("Error : ",e)
  }else{
     fmt.Println(n[0]["taskData"])
  }
  </code></pre>
  
  <p>getting output like this </p>
  
  <pre><code>map[owner_Uname:alice]
  </code></pre>
  
  <p>I need to access this resultant string with another query.
  It is a interface i tried to convert it to simple map 
  <code>newMap :=n[0]["taskData"].(map[string]interface{})</code>but it gives me an runtime error <code>interface conversion: interface {} is bson.M, not map[string]interface {}</code></p>
  
  <pre><code>result := rawData{}
  err := collection.Find(bson.M{"user_name":n[0]["taskData"]["owner_Uname"]}).All(&amp;result)
  </code></pre>
  
  <p>Now I want to use it in above query ...
  Kindly help me out. Thanks in advance </p>
  
  <p>Edit :-
  The data in mongo is like</p>
  
  <pre><code>{
     "_id" : ObjectId("56bf128f5a9a6a0ebfdd5075"),
       "deadLine" : {
         "Start_time" : ISODate("2016-05-24T00:00:00Z"),
         "End_time" : ISODate("2016-05-29T00:00:00Z")
       },
     },
     "taskData" : { 
         "createdOn" : ISODate("2016-02-20T21:23:11.903Z"), 
         "Task_content" : "@bob", 
         "Priority" : "2", 
         "owner_Uname" : "alice"
     },
     "group" : {
        "1" : {
          "grp_name" : "grp"
         },
        "2" : {
          "grp_name" : "secondGrp"
         }
      }
  </code></pre>
  
  <p>That will work me too if it is done with nested struct or map in struct </p>