开发者

DBIx::Class::ResultSet Update or Create on multiple unique constraints

开发者 https://www.devze.com 2023-03-12 12:52 出处:网络
I was wondering if it is possible update_or_开发者_如何学JAVAcreate on multiple unique constraints in dbix

I was wondering if it is possible update_or_开发者_如何学JAVAcreate on multiple unique constraints 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' }
  );


I figured it out: you have to define the unique constraint in the Controller with add_unique_constraint.

0

精彩评论

暂无评论...
验证码 换一张
取 消