Skip to content

Commit

Permalink
tech?(api): use batch insert to create jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
xav-car committed Sep 26, 2024
1 parent 246ce13 commit bc669fd
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ export class JobRepository {
async #send(jobs) {
const knexConn = DomainTransaction.getConnection();

return knexConn('pgboss.job').insert(jobs);
const results = await knexConn.batchInsert('pgboss.job', jobs);

// Sum the inserted row counts from the batch insert results
const rowCount = results.reduce((total, batchResult) => total + (batchResult.rowCount || 0), 0);

return { rowCount };
}

async performAsync(...datas) {
Expand Down

0 comments on commit bc669fd

Please sign in to comment.