Utility for performing transactional upserts (INSERT ... ON CONFLICT DO UPDATE) in PostgreSQL via Knex. Current version 0.1.1, no recent updates. Provides two functions: upsert (single row, no transaction) and transactionalUpsert (batch rows with transaction). Lightweight wrapper; no active maintenance. Differentiated by focusing solely on PostgreSQL upsert with a simple API and configurable batch size.
npm install knex-postgres-transactional-upsertNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initializes Knex with PostgreSQL, creates the upsert helper, and demonstrates both single and batch transactional upserts.
Wrap manual upsert calls in a Knex transaction, or use transactionalUpsert for batch operations.
Omit the primary key column from the fieldToTypeMap object.
Call the required function with a Knex instance, e.g., const upserters = require('knex-postgres-transactional-upsert')(knex, opts);Use require() and call the result: const upserters = require('knex-postgres-transactional-upsert')(knex);Use proper schema notation, e.g., 'public.tablename'.
Assign the factory result to a variable: const upserters = require('knex-postgres-transactional-upsert')(knex); then use upserters.upsert(...);