Skip to content

v0.16.0

Latest
Compare
Choose a tag to compare
@wsporto wsporto released this 28 Jan 00:31

Added

Postgres

Support for bulk insert using the COPY FROM statement

This new feature allows you to efficiently insert large datasets into the database with the COPY FROM statement.

Example usage:

  1. Write the SQL (bulk-insert-posts.sql)
COPY posts (
    title,
    body,
    user_id
)
FROM STDIN WITH CSV;
  1. You can use the generated bulkInsertPosts function to easily perform bulk inserts:
import pg from "pg";
const { Pool } = pg;
import { bulkInsertPosts } from "./sql";

const pool = new Pool({
    connectionString: 'postgres://postgres:password@127.0.0.1:5432/postgres'
});
const posts = //... // Array of post data

const client = await pool.connect();
await bulkInsertPosts(client, posts);

client.release();
await pool.end();

Full Changelog: v0.15.3...v0.16.0