[Dbix-class] doubt about has_many and update

Luca Ferrari fluca1978 at infinito.it
Mon Feb 2 15:11:23 GMT 2015


Hi all,
I've some confusion about the has_many relationship and how to quickly
update a set of value thru a join table.
I've a class Ticket with has_many Worker, and a join table.
The following works for adding a worker to a ticket:

 for my $current_worker (@workers){
            $ticket->add_to_tickets_workers( { pk_ticket =>
$ticket->pk,
                                               pk_worker =>
$current_worker->pk } ) if ( grep { $current_worker->pk == $_ }
@selected );


However I would like to have a set_tickets_workers behavior, so that I
can pass the array 8ref) of objects I want to substitute on the join
table.
Is there a way to do it or do I have to manually delete join rows (in
such case, how)?

Thanks,
Luca



More information about the DBIx-Class mailing list