You can't use unit['id'] in this context. That id is coincidentally named; there's no guarantee that every unit will have a field named "id". What's passed into this call as unit_id is the _id field of unit in its type collection as provided by mongo.