jspears / mers

Mongoose Express Rest Service
MIT License
342 stars 42 forks source link

Populate doesn't work with arrays #7

Closed pablodenadai closed 11 years ago

pablodenadai commented 11 years ago

var Player = new Schema({ name: { type: String, required: true }, });

var Match = new Schema({ players: [{ type: ObjectId, ref: 'Player' }], });

http://localhost:3000/rest/match/?populate=players

{"payload":[{"__v":1,"_id":"518e13d0a78e057873000001","players":["518e2cb42b8e61a48d000001","518e12e52bdbba9572000001"]}],"status":0,"total":1}

jspears commented 11 years ago

fixed in v0.6.2 Sorry about that, the populate is a hack. In some version of mongoose it started throwing exceptions if you tried to populate a non referenced field. This was very annoying because then you needed to know weather a field was a ref or not, to determine weather to populate it. This version fixes the issue you found with arrays.

Thank you so much for reporting!