wfc-db-sql
v1.0.0
Published
Spam Pairing Code Whatsapp
Readme
wfc-db-sql
A Node.js database client with query builder, streaming support, transaction and prepared statement for various databases.
Features
- Query Builder: Build complex SQL queries easily using Knex.js.
- Streaming Support: Handle large datasets efficiently with streaming queries.
- Transaction: Execute multiple queries in a single transaction to ensure data consistency.
- Prepared Statement: Prevent SQL injection and improve performance with prepared statements.
- Support multiple databases: Currently support PostgreSQL (can be extended to support other databases by changing knex configuration)
Installation
npm install wfc-db-sql
## EXAMPLE
const SimplePgClient = require('wfc-db-sql');
const config = {
user: 'your_user',
host: 'your_host',
database: 'your_database',
password: 'your_password',
port: 5432,
};
const client = new SimplePgClient(config);
async function test() {
try {
const users = await client.query('SELECT * FROM users');
console.log(users);
} catch (error) {
console.error('Error:', error);
} finally {
await client.close();
}
}
test();