lit-postgres
v1.0.0
Published
Postgres utility library
Downloads
3
Readme
Postgres
A PostgreSQL utility library aimed as serverless compute on AWS RDS.
Install
npm install lit-postgres --save
SQL tagged template
sql
Construct SQL queries using a tagged template. The function translates queries into a native Postgres parameterized query to help prevent SQL injections.
The function automatically creates a pooled database connection and connects to the databse specified by standard pg environment variables.
const greeting = "Hello, world!";
const { rows, rowCount } =
await sql`select ${greeting}::text as "message"`;
Inspiration
Inspired by @vercel/postgres
and the proliferaion of .sql
files in Node.js applications which introduces blocking io to read and is rarely cached.