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.
npm install easy-database-connectorVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic querying, cached pagination, encrypted data insertion, and transaction management using the library's core functions.
Ensure all required environment variables (e.g., DB_HOST, DB_USER, REDIS_HOST) are correctly defined and loaded before application startup (e.g., using `dotenv/config`).
Consult MSSQL documentation for setting up database encryption. Verify that `MSSQL_SYNNETRIC_KEY_NAME`, `MSSQL_CERTIFICATE_NAME`, and `MASTER_KEY_PASSWORD` in your .env correctly reference existing and accessible SQL Server encryption objects.
Ensure a Redis server is accessible from your application and `REDIS_ENABLED=true`, `REDIS_HOST`, `REDIS_PORT`, `REDIS_PASSWORD` (if applicable) are correctly set in your .env file.
Carefully match the `ColumnType` definitions in `bulk.columns` to the exact data types and lengths of your target SQL Server table columns. Import `mssql` types if needed for type definitions.
Verify that `DB_USER`, `DB_PASSWORD`, `DB_HOST`, `DB_PORT`, and `DB_DATABASE` are correctly configured in your `.env` file and that the user has appropriate database permissions.
Ensure all mandatory database configuration variables (e.g., `DB_TYPE`, `DB_HOST`, `DB_USER`, `DB_PASSWORD`, `DB_DATABASE`, `DB_PORT`, `DB_ENCRYPT`) are present and correctly named in your `.env` file.
Confirm that your SQL Server database has the necessary master key and symmetric key/certificate created and that the `MASTER_KEY_PASSWORD`, `MSSQL_SYNNETRIC_KEY_NAME`, and `MSSQL_CERTIFICATE_NAME` in your `.env` file match the database configuration.