I made a multiple-insert as well as other methods for Mojo::Pg

The code is in this gist

insert_multi_p will let you insert multiple rows in Postgres with a single query, like this:


await $db->insert_multi_p(
    'table_name',
    [
       {
          ... anything you'd be able to write in insert_p ...
       },
       {
           ... second row to insert ...
       },
       ... etc ...
    ],
    {
         ...normal pg insert options...
    },
);

Lots of other interesting methods in there, that I use in my projects.

You can use this Role in your postgres object as follows:


my $pg = Mojo::Pg->new($db_string)->database_class(Mojo::Pg::Database->with_roles('+MyApp'));

Leave a comment

About karjala

user-pic I'm a Perl developer.