update incrementing value (postgres)

So, i have a table:
export const VisitorCount = pgTable('visitor-count', {
  id: bigserial('id', { mode: 'number' }).primaryKey(),
  experimentId: bigint('experiment_id', { mode: 'number' }),
  variantId: bigint('variant_id', { mode: 'number' }),
  count: bigint('count', { mode: 'number' }).default(0),
});


at the time i want to do the update, i know the required rows are there, initialized at 0

and i'll do batch updates with objects that look like:
{
  '8-25': 4,
  '8-26': 4,
  '8-23': 3,
  '8-22': 3,
  '8-24': 4,
};


where "8" is experimentId, "25" is variantId and i want to update the relevant line, adding
4
to the existing value that was there before...

Is there a good way to do this?
Was this page helpful?