Registry /
database / easy-database-connector
easy-database-connector, currently at version 1.4.1, is a TypeScript-first database connector library primarily designed for MSSQL (SQL Server) environments. It offers a comprehensive suite of features aimed at enhancing performance, security, and developer productivity. Key functionalities include connection pooling for optimal performance, built-in encryption for sensitive data, and integrated Redis caching for pagination and general query results. The library provides robust transaction management, supports bulk operations, and offers type-safe querying with full TypeScript backing. While specific release cadence is not explicitly stated, its current version suggests active development. Its differentiators lie in its all-in-one approach to common database concerns for MSSQL, providing encryption, caching, and robust operations within a single, coherent API, unlike more minimalist ORMs or query builders.
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Primarily used for SELECT operations with optional caching.
import { query } from 'easy-database-connector';
Used for INSERT, UPDATE, DELETE, and bulk operations.
import { execute } from 'easy-database-connector';
Provides a robust mechanism for running multiple queries within a single database transaction.
import { transaction } from 'easy-database-connector';
This quickstart demonstrates basic querying, cached pagination, encrypted data insertion, and transaction management using the library's core functions.
import { query, execute, queryWithPagination, transaction } from 'easy-database-connector';
import 'dotenv/config'; // Ensure environment variables are loaded
interface User {
id: number;
name: string;
email: string;
active: boolean;
}
async function runExample() {
// Basic query
const users = await query<User>({
sql: 'SELECT * FROM users WHERE active = @p0',
parameters: [true]
});
console.log('Active users:', users);
// Paged query with caching
const pagedUsers = await queryWithPagination<User>({
sql: 'SELECT * FROM users',
parameters: [],
page: 1,
pageSize: 10,
orderBy: 'name ASC',
cache: {
key: 'users:page1',
ttl: 300 // 5 minutes
}
});
console.log('Paged users:', pagedUsers.rows);
// Encrypted data insertion (requires MSSQL encryption setup)
// Ensure environment variables for encryption are set: MSSQL_SYNNETRIC_KEY_NAME, MSSQL_CERTIFICATE_NAME, MASTER_KEY_PASSWORD
try {
await execute({
sql: 'INSERT INTO secure_data (data) VALUES (@p0)',
parameters: ['sensitive information'],
encryption: {
open: { aes: true, masterkey: true },
data: ['0']
}
});
console.log('Sensitive data inserted (encrypted).');
} catch (e) {
console.error('Failed to insert encrypted data. Check MSSQL encryption setup and .env config.', e);
}
// Transaction example
await transaction(async (trx) => {
await execute({
sql: 'INSERT INTO users (name) VALUES (@p0)',
parameters: ['John Doe'],
transaction: trx
});
await execute({
sql: 'INSERT INTO logs (action) VALUES (@p0)',
parameters: ['user_john_created'],
transaction: trx
});
});
console.log('Transaction completed: User and log created.');
}
runExample().catch(console.error);
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.