postgresql-client
Advanced tools
Comparing version 2.5.3 to 2.5.5
{ | ||
"name": "postgresql-client", | ||
"description": "Enterprise level PostgreSQL client for JavaScript", | ||
"version": "2.5.3", | ||
"version": "2.5.5", | ||
"author": "Panates", | ||
@@ -29,4 +29,5 @@ "contributors": [ | ||
"@types/node": "^18.14.0", | ||
"@typescript-eslint/eslint-plugin": "^5.52.0", | ||
"@typescript-eslint/parser": "^5.52.0", | ||
"@typescript-eslint/eslint-plugin": "^5.53.0", | ||
"@typescript-eslint/parser": "^5.53.0", | ||
"auto-changelog": "^2.4.0", | ||
"dotenv": "^16.0.3", | ||
@@ -63,3 +64,4 @@ "eslint": "^8.34.0", | ||
"precitest": "rimraf coverage", | ||
"citest": "jest --coverage --coverageReporters=lcov" | ||
"citest": "jest --coverage --coverageReporters=lcov", | ||
"version": "auto-changelog -p && git add CHANGELOG.md" | ||
}, | ||
@@ -84,8 +86,11 @@ "type": "module", | ||
"LICENSE", | ||
"README.md" | ||
"README.md", | ||
"CHANGELOG.md" | ||
], | ||
"keywords": [ | ||
"pg", | ||
"backend", | ||
"frontent", | ||
"postgresql", | ||
"postgres", | ||
"pg", | ||
"postgre", | ||
@@ -92,0 +97,0 @@ "driver", |
@@ -50,10 +50,16 @@ ## postgresql-client | ||
import {Connection} from 'postgresql-client'; | ||
// Create connection | ||
const connection = new Connection('postgres://localhost'); | ||
// Connect to database server | ||
await connection.connect(); | ||
// Execute query and fetch rows | ||
const result = await connection.query( | ||
'select * from cities where name like $1', | ||
{params: ['%york%']}); | ||
const rows = result.rows; | ||
await connection.close(); // Disconnect | ||
const rows: any[] = result.rows; | ||
// Do what ever you want with rows | ||
// Disconnect from server | ||
await connection.close(); | ||
``` | ||
@@ -65,2 +71,3 @@ | ||
// Create connection pool | ||
const db = new Pool({ | ||
@@ -75,12 +82,18 @@ host: 'postgres://localhost', | ||
// Execute query and fetch cursor | ||
const result = await db.query( | ||
'select * from cities where name like $1', | ||
{params: ['%york%'], cursor: true}); | ||
// Walk through the cursor, and do whatever you want with fetched rows | ||
const cursor = result.cursor; | ||
let row; | ||
while ((row = cursor.next())) { | ||
while ((row = await cursor.next())) { | ||
console.log(row); | ||
} | ||
// Close cursor, (Send connection back to the pool) | ||
await cursor.close(); | ||
await db.close(); // Disconnect all connections and shutdown pool | ||
// Disconnect all connections and shutdown pool | ||
await db.close(); | ||
``` | ||
@@ -87,0 +100,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
388248
170
198
23