0

I understand in dbic that many-to-many isn't a real relationship and what I've done up until now is used the add_to_$rel function.

Is it possible to structure my many-to-many data in such a way that I can insert it using multicreate?

Many thanks

user1768233
  • 1,409
  • 3
  • 20
  • 28

1 Answers1

0

many-to-many are not relationships but relationship helpers, see https://metacpan.org/pod/DBIx::Class::Relationship#many_to_many.

You need to use the two underlying relationships for the data structure you're passing to create:

$rs->create({
    rel_to_bridge_table => {
        column_in_bridge_table => 'foo',
        rel_to_remote_table => {
            col1 => 'bar',
            col2 => 'baz',
        }
    }
});
Alexander Hartmaier
  • 2,178
  • 12
  • 21