@scmbwis/bpg-lib
v0.2.0
Published
Production runtime SQL and application helpers for BPG generated database models
Downloads
298
Readme
bpg-lib
Production runtime library for applications that use database models generated by bpg-gen.
Put shared SQL execution, query builders, CRUD helpers, Nest helpers, DTO helpers, and other runtime utilities here.
Install
Public npm package:
npm install @scmbwis/bpg-lib pgUse
Configure the PostgreSQL runtime once at application startup:
import { Pool } from 'pg'
import { configurePgRuntime } from '@scmbwis/bpg-lib'
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
})
configurePgRuntime({
pgClient: pool,
})Generated table metadata can then be passed into the query helpers:
import { dbSelect, dbInsert } from '@scmbwis/bpg-lib'
import { userTable } from './generated/db'
const users = await dbSelect(userTable)
const ids = await dbInsert({
table: userTable,
data: { displayName: 'Ada Lovelace' },
})Build
npm run buildPublish
npm login
npm publishpublishConfig.access=public is already set for public scoped npm publishing.
