* Jason Kohles <[EMAIL PROTECTED]> [2007-08-22 16:35]: > There is probably a cleaner way, but this is how I'm doing it > at the moment...
There certainly is. sub update_profiles { my ( $self, @profiles ) = @_; my %new_profile = map { ( $_, $_ ) } @profiles; # first kill existing profile links that don't show up in the new list $self->profiles->search( { profile_id => { -not_in => @profile } } )->delete; # then disregard profile links that are still in the database delete @new_profile{ map { $_->profile_id } $self->profiles }; # and finally create the ones that aren't yet $self->add_to_profiles( { profile_id => $_ } ) for values %new_profile; return $self; } Untested. Regards, -- Aristotle Pagaltzis // <http://plasmasturm.org/> _______________________________________________ List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]