Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@pgtyped/cli with postgres.js #576

Open
sudowoodo200 opened this issue Apr 16, 2024 · 0 comments
Open

@pgtyped/cli with postgres.js #576

sudowoodo200 opened this issue Apr 16, 2024 · 0 comments

Comments

@sudowoodo200
Copy link

Is your feature request related to a problem? Please describe.
I think postgres.js is the best query client out there and includes it's own type hinting facility as well. Instead of bridging pgtyped connection from pg to postgres.js, why not enable usage of the postgres.js client while still using @pgtyped/cli? This also gets us transactions for free.

Describe the solution you'd like
Have the cli read and generate postgres.js sql queries, which differ from @pgtyped/runtime sql in their use of templates. For instance

// postgres.js
await sql`SELECT * from users where id = ${userID}`

can be augmented into

await sql<Users[]>`SELECT * from users where id = ${userID}`

The list of dynamic query templating is finite: https://github.com/porsager/postgres?tab=readme-ov-file#queries

Additional context
Would love postgres.js to collab too, but thought it'd be straightfwd to support it in the cli here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant