Open its-dibo opened 1 year ago
fwiw there is very, very little (if any) code that would be removed with tree-shaking if you are importing the pool. It literally depends on all the code in the project.
is the documentation wrong? @brianc https://node-postgres.com/
import { Client } from 'pg'
const client = new Client()
await client.connect()
const res = await client.query('SELECT $1::text as message', ['Hello world!'])
console.log(res.rows[0].message) // Hello world!
await client.end()
I'm open to a pull request to add ESM support so long as it maintains backwards compatibility.
I will take a look @brianc maybe in this weekend
Hello, and thank you for the library @brainc <3
I got to this issue because the docs imply this type of import is supported here: https://node-postgres.com/apis/pool
import { Pool } from 'pg'
const pool = new Pool({
host: 'localhost',
user: 'database-user',
max: 20,
idleTimeoutMillis: 30000,
connectionTimeoutMillis: 2000,
})
Should the docs be updated to the following?
import pg from 'pg'
const pool = new pg.Pool({
host: 'localhost',
user: 'database-user',
max: 20,
idleTimeoutMillis: 30000,
connectionTimeoutMillis: 2000,
})
I'm open to a pull request to add ESM support so long as it maintains backwards compatibility.
nice <3
Why is the documentation written in a way that clearly doesn’t work?
FFS 07.2024 and the docs are stil not changed.
are the docs inaccurate? If so it would be helpful if you would point out where. I went through a while ago and tried to make them all clear and correct. You could also do a PR with the changes if that's easier.
when running this package inside an ESM project, I got this error
using the suggested form
import pkg from 'pg';
disables the tree-shaking