stabilize-orm 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +45 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,9 +1,52 @@
1
1
  # Stabilize ORM
2
2
 
3
- A lightweight, type-safe ORM for Bun.js, supporting SQLite, MySQL, PostgreSQL, and Redis caching.
3
+ Stabilize is a lightweight, retry-aware ORM built on Bun's native SQL API. It provides a unified interface for SQLite, MySQL, and PostgreSQL with features like connection pooling, automatic retries, transactions, savepoints, and logging. It's designed for simplicity, performance, and stability in Bun applications.
4
+
5
+ ## Features
6
+
7
+ - **Unified API**: Works seamlessly with SQLite, MySQL, and PostgreSQL via Bun SQL.
8
+ - **Retry Logic**: Automatic exponential backoff retries for queries and transactions.
9
+ - **Connection Management**: Pooling, switching connections, and metrics.
10
+ - **Transactions & Savepoints**: Built-in support with retry handling.
11
+ - **Prepared Statements**: Cached for SQLite to improve performance.
12
+ - **Logging**: Pluggable logger (default: ConsoleLogger).
13
+ - **Error Handling**: Custom `StabilizeError` with database-specific codes.
14
+ - **CLI**: Simple command-line tool for database operations (e.g., migrations, queries).
4
15
 
5
16
  ## Installation
6
17
 
18
+ Stabilize requires Bun (v1.0+).
19
+
7
20
  ```bash
8
- bun add stabilize
21
+ # Install via bun
22
+ bun add stabilize-orm
9
23
  ```
24
+ ## Usage
25
+
26
+ ```bash
27
+ # Imports
28
+ import { DBClient } from 'stabilize-orm/src/client';
29
+ import { DBConfig } from 'stabilize-orm/src/types';
30
+
31
+ const config: DBConfig = {
32
+ type: 'sqlite', // or 'mysql', 'postgres'
33
+ connectionString: 'sqlite://myapp.db',
34
+ poolSize: 10,
35
+ retryAttempts: 3,
36
+ };
37
+
38
+ const db = new DBClient(config);
39
+
40
+ async function run() {
41
+ const users = await db.query<{ id: number; name: string }>('SELECT * FROM users');
42
+ console.log(users);
43
+
44
+ await db.transaction(async () => {
45
+ await db.query('INSERT INTO users (name) VALUES (?)', ['Alice']);
46
+ });
47
+
48
+ await db.close();
49
+ }
50
+
51
+ run();
52
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stabilize-orm",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "A lightweight, type-safe ORM for Bun.js with support for SQLite, MySQL, PostgreSQL, and Redis caching",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",