{"issue":{"pull_request":{"diff_url":null,"html_url":null,"patch_url":null},"state":"open","milestone":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/1363d3abc6dadd713cec939a1076f3b0?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"1363d3abc6dadd713cec939a1076f3b0","url":"https://api.github.com/users/dmmalam","login":"dmmalam","id":19739},"assignee":null,"updated_at":"2011-11-15T16:54:43Z","labels":[],"closed_at":null,"comments":5,"url":"https://api.github.com/repos/LearnBoost/mongoose/issues/601","body":"Hey, \r\nI have the following schemas ( simplified for issue)\r\n\r\nUser = new Schema \r\n  login:String\r\n\r\nA = new Schema\r\n emb: [B]\r\n comments: [Comments]\r\n\r\n//and following embedded schemas\r\n\r\nB = new Schema\r\n  comments: [Comments]\r\n\r\nComments = new Schema\r\n   creator:\r\n    type: ObjectId\r\n    ref: 'User'\r\n  message: String\r\n\r\n\r\nNow while populate works on A\r\neg A.find().populate('comments.creator')\r\n\r\nit doesn't work on the double nested embedded doc\r\neg A.find().populate('emb.comments.creator')\r\n\r\nAny ideas?\r\n\r\n\r\n","html_url":"https://github.com/LearnBoost/mongoose/issues/601","title":"Calling populate on embedded doc of embedded doc","number":601,"id":2174853,"created_at":"2011-11-08T14:44:27Z"},"action":"created","comment":{"user":{"avatar_url":"https://secure.gravatar.com/avatar/67272962bf40e6e767609a57bc000496?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"67272962bf40e6e767609a57bc000496","url":"https://api.github.com/users/paulshapiro","login":"paulshapiro","id":438826},"updated_at":"2011-11-15T16:54:43Z","url":"https://api.github.com/repos/LearnBoost/mongoose/issues/comments/2747550","body":"Ah, thanks for your detailed answer. Your mongoose calls are more specific than mine and I could learn from your approach. As it happens my particular application required a recursive populate, so for now I may be stuck doing this manually.\r\n\r\nI end up doing something like this.\r\n\r\n    var viewWithId_forDisplay = function(id, callback) {\r\n\tif ( !id || typeof id === 'undefined' || id.toString().match(app_utils.emptyReg) ) {\r\n\t\tthrow new Error('Bad user ID.');\r\n\t}\r\n\r\n\tView.findById(id)\r\n\t.run(function(err, obj) {\r\n\t\tif ( err || !obj || !obj.subviews || !obj.subviews.length ) return callback(err, obj);\r\n\r\n\t\tobj = obj.toObject();\r\n\r\n\t\t// recursive subview fetch\r\n\t\tasync.map( obj.subviews, viewWithId_forDisplay, function(err, results) {\r\n\t\t\tobj.subviews = results;\r\n\t\t\t\r\n\t\t\treturn callback(err, obj);\r\n\t\t} );\r\n\r\n\t})\r\n    }","id":2747550,"created_at":"2011-11-15T16:54:43Z"}}