Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
PostgreJS is a enterprise-level PostgreSQL client for Node.js. It is designed to provide a robust and efficient interface to PostgreSQL databases, ensuring high performance and reliability for enterprise applications. Written entirely in TypeScript, it leverages modern JavaScript features to deliver a seamless development experience.
PostgreJS is a pure JavaScript library, meticulously crafted with TypeScript to offer a strictly typed, well-structured, and highly maintainable codebase. Key highlights include:
Whether you're building a simple application or a complex enterprise system, PostgreJS provides the features and performance you need to succeed. Explore the capabilities of the library and elevate your PostgreSQL integration to the next level.
$ npm install postgrejs --save
Please read :small_orange_diamond: DOCUMENTATION :small_orange_diamond: for detailed usage.
import {Connection} from 'postgrejs';
// 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: any[] = result.rows;
// Do what ever you want with rows
// Disconnect from server
await connection.close();
import {Pool} from 'postgrejs';
// Create connection pool
const db = new Pool({
host: 'postgres://localhost',
pool: {
min: 1,
max: 10,
idleTimeoutMillis: 5000
}
});
// 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 = await cursor.next())) {
console.log(row);
}
// Close cursor, (Send connection back to the pool)
await cursor.close();
// Disconnect all connections and shutdown pool
await db.close();
import {DataTypeOIDs} from 'postgrejs';
// .....
const statement = await connection.prepare(
'insert into my_table(id, name) values ($1, $2)', {
paramTypes: [DataTypeOIDs.Int4, DataTypeOIDs.Varchar]
});
for (let i = 0; i < 100; i++) {
await statement.execute({params: [i, ('name' + i)]});
}
await statement.close(); // When you done, close the statement to relase resources
The table below lists builtin data type mappings.
PosgtreSQL type | JS type | Receive | Send |
---|---|---|---|
bool | boolean | text,binary | binary |
int2 | number | text,binary | binary |
int4 | number | text,binary | binary |
int8 | BigInt | text,binary | binary |
float4 | number | text,binary | binary |
float8 | number | text,binary | binary |
char | string | text,binary | binary |
bpchar | string | text,binary | binary |
varchar | string | text,binary | binary |
date | Date | text,binary | binary |
time | Date | text,binary | binary |
timestamp | Date | text,binary | binary |
timestamptz | Date | text,binary | binary |
oid | number | text,binary | binary |
bytea | Buffer | text,binary | binary |
uuid | string | text,binary | binary |
json | object | text,binary | binary |
jsonb | object | text,binary | binary |
xml | string | text,binary | binary |
point | Point | text,binary | binary |
circle | Circle | text,binary | binary |
lseg | Rectangle | text,binary | binary |
box | Rectangle | text,binary | binary |
int2Vector | number[] | text,binary | binary |
_bool | boolean[] | text,binary | binary |
_int2 | number[] | text,binary | binary |
_int4 | number[] | text,binary | binary |
_int8 | BigInt[] | text,binary | binary |
_float4 | number[] | text,binary | binary |
_float8 | number[] | text,binary | binary |
_char | string[] | text,binary | binary |
_bpchar | string[] | text,binary | binary |
_varchar | string[] | text,binary | binary |
_date | Date[] | text,binary | binary |
_time | Date[] | text,binary | binary |
_timestamp | Date[] | text,binary | binary |
_timestamptz | Date[] | text,binary | binary |
_uuid | string[] | text,binary | binary |
_oid | number[] | text,binary | binary |
_bytea | Buffer[] | text,binary | binary |
_json | object[] | text,binary | binary |
_jsonb | object[] | text,binary | binary |
_xml | string[] | text,binary | binary |
_point | Point[] | text,binary | binary |
_circle | Circle[] | text,binary | binary |
_lseg | Rectangle[] | text,binary | binary |
_box | Rectangle[] | text,binary | binary |
_int2Vector | number[][] | text,binary | binary |
You can report bugs and discuss features on the GitHub issues page When you open an issue please provide version of NodeJS and PostgreSQL server.
node >= 16.x
postgrejs is available under MIT license.
FAQs
Professional PostgreSQL client NodeJS
The npm package postgrejs receives a total of 14,899 weekly downloads. As such, postgrejs popularity was classified as popular.
We found that postgrejs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.