DBIx::Class::ResultSet 在多个唯一约束上更新或创建
我想知道是否可以对 dbix
Ex From Cpan 中的多个唯一约束进行 update_or_create:
my $cd = $schema->resultset('CD')->update_or_create(
{
artist => 'Massive Attack',
title => 'Mezzanine',
year => 1998,
},
{ key => 'cd_artist_title' }
);
我想做什么
my $cd = $schema->resultset('CD')->update_or_create(
{
artist => 'Massive Attack',
title => 'Mezzanine',
year => 1998,
},
{ key => {'cd_artist_title','year' }
);
I was wondering if it is possible update_or_create 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' }
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想通了:您必须使用
在控制器中定义唯一约束add_unique_constraint
。I figured it out: you have to define the unique constraint in the Controller with
add_unique_constraint
.