Finding embeded document in mongodb?

My collection is like this

{
  "name":""
  "type":""
  "arr":[
   {
     "type":""
     "other field"
     ...
   },
  {
     "type":""
     "other field"
     ...
   }
}

and my condition is input parameter is name. so based on name i have to fetch document and one more condition is that type outside and inside the array should match.. Need to fetch those records alone.. How to achieve this

If I understand you correctly, this is how you get the desired result

{name:"",type:"",arr.type:""}

you can put the desired values and it will return you all the matching record.

Bad performance, but just work (http://docs.mongodb.org/manual/reference/operator/where)

db.SOME_COLLECTION.find({
  name:'SOME_VALUE', 
  $where: 
    function() {
      for(var i = 0; i < obj.arr.length; i++) {
        if(obj.arr[i].type==obj.type) {
          return obj
        }
      }
    }
  }
)

p.s. aggregation framework has solved analogical problems, but in this case, imho, only $where clause available