timbunce / WebAPI-DBIC

A composable RESTful JSON API to DBIx::Class schemas using roles and Web::Machine. PLEASE NOTE This module is no longer under active development. If you're interested in helping to develop or maintain it please fork it.
26 stars 10 forks source link

Handle has_many relationship lookups via prefetch #6

Closed ungrim97 closed 9 years ago

ungrim97 commented 10 years ago

Currently we only handle single type relationships (has_one, might_have and belongs_to). We should be able to handle multi relationships such as many_to_many and has_many in prefetch. e.g

 Artist->has_many(cds => 'MySchema::Result::CD, 'artist_id');

 /artist/1?prefetch=cds

 {_embedded => {
     cds => [{artist_id: 1, title: Test}, {artist_id: 1, title: Oldies}],
 }}
timbunce commented 9 years ago

Any chance of a test for this one?