mysociety / popit-api

DEPRECATED - Development on PopIt has stopped and it is no longer being maintained
https://goo.gl/Vvej4Q
Other
17 stars 3 forks source link

Don't embed memberships unless requested #87

Closed chrismytton closed 9 years ago

chrismytton commented 9 years ago

This changes the way that memberships are embedded with the ?embed parameter. If you just provide 'membership' then the first layer of memberships are populated (the default behaviour), 'membership.person' will populate the people in the first layer of memberships, but not those peoples memberships, 'membership.person.membership' will populate the people's memberships as well. The same goes for organizations.

I've changed the embed population to be a mongoose plugin, which tidies up the code in src/app.js a bit to just call a method on the model.

I've also removed the recursive membership population in favour of using the async module, which makes it a bit easier for my brain to grok.

Fixes https://github.com/mysociety/popit/issues/634

struan commented 9 years ago

Woo! This is much neater and more pleasant. Other than teeny validation thing it looks good.