DataZen is a TypeScript-first DBAL (Database Abstraction Layer) inspired by Doctrine DBAL. It targets teams who want SQL-first development with a stable runtime abstraction, without adopting a full ORM.
Using Bun:
bun add @devscast/datazen mysql2For SQL Server projects:
bun add @devscast/datazen mssqlmysql2 and mssql are peer dependencies so applications control driver versions.
- Introduction
- Architecture
- Configuration
- Data Retrieval and Manipulation
- Query Builder
- Types
- Portability
- Platforms
- Transactions
- Security
- Known Vendor Issues
- Supporting Other Databases
import mysql from "mysql2/promise";
import { DriverManager } from "@devscast/datazen";
const pool = mysql.createPool({
database: "mydb",
host: "localhost",
password: "secret",
user: "user",
});
const conn = DriverManager.getConnection({
driver: "mysql2",
pool,
});
const value = await conn.fetchOne("SELECT 1");import sql from "mssql";
import { DriverManager } from "@devscast/datazen";
const pool = await sql.connect({
database: "mydb",
options: { encrypt: true, trustServerCertificate: true },
password: "secret",
server: "localhost",
user: "user",
});
const conn = DriverManager.getConnection({
driver: "mssql",
pool,
});
const value = await conn.fetchOne("SELECT 1");const qb = conn
.createQueryBuilder()
.select("u.id", "u.email")
.from("users", "u")
.where("u.email = :email")
.setParameter("email", "john@example.com");
const user = await qb.fetchAssociative();This project is fully inspired by the architecture and design of doctrine/dbal.
DataZen is an independent TypeScript/Node implementation and is not affiliated with Doctrine.