Non-blocking OpenGauss/PostgreSQL client for Node.js with pure JavaScript implementation.
A hybrid database client that supports both OpenGauss and PostgreSQL connections simultaneously, based on:
✅ Key Features
- Dual-database support with type switching
- Compatibility with
Knex.js
and other query builders - Native promise-based API
- Connection pooling support
- Enables smooth transition of existing Knex.js applications from PostgreSQL to OpenGauss with schema compatibility
npm install opengauss.js
const { Client } = require("opengauss.js");
const client = new Client({
// Base configuration (inherited from node-postgres)
user: 'dbuser',
password: 'secretpassword',
host: 'database.server.com',
port: 3211,
database: 'mydb',
// Key parameter [required]
databaseType: 'openGauss' // Options: 'openGauss' | 'postgre' | 'pg' (Default: 'openGauss')
});
Seamless replacement via npm alias:
// package.json
{
...,
"dependencies": {
"pg": "npm:opengauss.js@^1.1.0"
}
}
Knex configuration
const knex = require('knex')({
client: 'pg',
connection: {
databaseType: 'openGauss', // Specify database type
// ...other standard pg configurations
host: '127.0.0.1',
},
version: "9.2"
});