[英]DBIx::Class::ResultSet Update or Create on multiple unique constraints
I was wondering if it is possible update_or_create on multiple unique constraints in dbix我想知道是否可以在 dbix 中的多个唯一约束上进行 update_or_create
Ex From Cpan:来自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
.我想通了:您必须使用
add_unique_constraint
在 Controller 中定义唯一约束。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.