DBIx :: Class :: ResultSet Update or Create with Several Unique Constraints

I was wondering if update_or_create is possible for a lot of unique limitations in dbix

Ex from Cpan:

 my $cd = $schema->resultset('CD')->update_or_create(
    {
      artist => 'Massive Attack',
      title  => 'Mezzanine',
      year   => 1998,
    },
    { key => 'cd_artist_title' }
  );

What i would like to do

   my $cd = $schema->resultset('CD')->update_or_create(
    {
      artist => 'Massive Attack',
      title  => 'Mezzanine',
      year   => 1998,
    },
    { key => {'cd_artist_title','year' }
  );
+5
source share
1 answer

I realized: you need to define a unique constraint in the controller with add_unique_constraint.

+4
source

All Articles