For the simple case of two tables - the term and the definition - where is the Term has_manyDefinitions and the definition belongs_toThe term, all members and corresponding definitions must be extracted and displayed in some way.
Here is what I came up with so far:
my $terms= $schema->resultset('Term')->search(undef, {
prefetch => 'definitions',
});
while (my $term = $terms->next) {
my @terms;
push @terms, $term->term;
my $definitions = $term->definitions;
my @definitions;
while (my $definition = $definitions->next) {
push @definitions, $definitions;
}
...
}
He does the job, but I was wondering if a different, less violent approach could be made.
source
share