@boostkit/orm-drizzle 0.0.1

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 BoostKit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,207 @@
1
+ # @boostkit/orm-drizzle
2
+
3
+ Drizzle ORM adapter for Forge. Implements the `OrmAdapterProvider` / `OrmAdapter` / `QueryBuilder<T>` contract using Drizzle's SQL-like fluent API.
4
+
5
+ ---
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pnpm add @boostkit/orm-drizzle drizzle-orm
11
+ ```
12
+
13
+ Install the driver for your database:
14
+
15
+ | Driver | Package |
16
+ |--------|---------|
17
+ | SQLite (default) | `better-sqlite3` + `@types/better-sqlite3` |
18
+ | LibSQL / Turso | `@libsql/client` |
19
+ | PostgreSQL | `postgres` |
20
+
21
+ ```bash
22
+ # SQLite
23
+ pnpm add better-sqlite3
24
+ pnpm add -D @types/better-sqlite3
25
+
26
+ # LibSQL / Turso
27
+ pnpm add @libsql/client
28
+
29
+ # PostgreSQL
30
+ pnpm add postgres
31
+ ```
32
+
33
+ ---
34
+
35
+ ## Defining a Drizzle Schema
36
+
37
+ Unlike Prisma, Drizzle is schema-first in TypeScript. You define table objects that the adapter uses to build queries.
38
+
39
+ ```ts
40
+ // app/schema.ts
41
+ import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core'
42
+
43
+ export const users = sqliteTable('users', {
44
+ id: text('id').primaryKey(),
45
+ name: text('name').notNull(),
46
+ email: text('email').notNull().unique(),
47
+ role: text('role').notNull().default('user'),
48
+ })
49
+
50
+ export const posts = sqliteTable('posts', {
51
+ id: integer('id').primaryKey({ autoIncrement: true }),
52
+ title: text('title').notNull(),
53
+ userId: text('user_id').notNull(),
54
+ })
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Wiring in DatabaseServiceProvider
60
+
61
+ Pass your table schemas to the `drizzle()` factory via the `tables` map:
62
+
63
+ ```ts
64
+ // app/Providers/DatabaseServiceProvider.ts
65
+ import { ServiceProvider } from '@boostkit/core'
66
+ import { drizzle } from '@boostkit/orm-drizzle'
67
+ import { ModelRegistry } from '@boostkit/orm'
68
+ import { users, posts } from '../schema.js'
69
+
70
+ export class DatabaseServiceProvider extends ServiceProvider {
71
+ async boot(): Promise<void> {
72
+ const adapter = await drizzle({
73
+ driver: 'sqlite', // 'sqlite' | 'postgresql' | 'libsql'
74
+ url: process.env['DATABASE_URL'] ?? 'file:./dev.db',
75
+ tables: {
76
+ users, // tableName used in Model.table → drizzle table object
77
+ posts,
78
+ },
79
+ }).create()
80
+
81
+ await adapter.connect() // no-op — Drizzle connects lazily
82
+ ModelRegistry.set(adapter)
83
+ this.app.instance('db', adapter)
84
+ }
85
+ }
86
+ ```
87
+
88
+ ### Model definition
89
+
90
+ ```ts
91
+ // app/Models/User.ts
92
+ import { Model } from '@boostkit/orm'
93
+
94
+ export class User extends Model {
95
+ static table = 'users' // must match the key in tables: {}
96
+ id!: string
97
+ name!: string
98
+ email!: string
99
+ role!: string
100
+ }
101
+ ```
102
+
103
+ ---
104
+
105
+ ## Using a Pre-built Drizzle Instance
106
+
107
+ If you already have a Drizzle `db` instance (e.g. from better-auth or custom setup), pass it directly:
108
+
109
+ ```ts
110
+ import { drizzle as dzCreate } from 'drizzle-orm/better-sqlite3'
111
+ import Database from 'better-sqlite3'
112
+ import { users } from '../schema.js'
113
+
114
+ const db = dzCreate(new Database('./dev.db'))
115
+
116
+ const adapter = await drizzle({
117
+ client: db,
118
+ tables: { users },
119
+ }).create()
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Global Table Registry
125
+
126
+ As an alternative to passing `tables` in config, register tables globally — useful when tables are defined across multiple modules:
127
+
128
+ ```ts
129
+ // bootstrap/app.ts or a service provider
130
+ import { DrizzleTableRegistry } from '@boostkit/orm-drizzle'
131
+ import { users, posts } from '../app/schema.js'
132
+
133
+ DrizzleTableRegistry.register('users', users)
134
+ DrizzleTableRegistry.register('posts', posts)
135
+ ```
136
+
137
+ The adapter checks `tables` config first, then falls back to `DrizzleTableRegistry`.
138
+
139
+ ---
140
+
141
+ ## Drivers
142
+
143
+ ### SQLite (default)
144
+
145
+ ```ts
146
+ drizzle({ driver: 'sqlite', url: 'file:./dev.db', tables })
147
+ // url defaults to DATABASE_URL env var, then 'file:./dev.db'
148
+ ```
149
+
150
+ ### LibSQL / Turso
151
+
152
+ ```ts
153
+ drizzle({ driver: 'libsql', url: 'libsql://your-db.turso.io?authToken=...', tables })
154
+ ```
155
+
156
+ ### PostgreSQL
157
+
158
+ ```ts
159
+ drizzle({ driver: 'postgresql', url: 'postgres://user:pass@localhost/mydb', tables })
160
+ ```
161
+
162
+ ---
163
+
164
+ ## API Reference
165
+
166
+ All methods mirror the `@boostkit/orm` `QueryBuilder<T>` contract:
167
+
168
+ | Method | Description |
169
+ |--------|-------------|
170
+ | `where(col, value)` | Equality filter |
171
+ | `where(col, op, value)` | Filter with operator (`=`, `!=`, `>`, `>=`, `<`, `<=`, `LIKE`, `IN`, `NOT IN`) |
172
+ | `orWhere(col, value)` | Appends additional equality filter (joined with `AND` internally) |
173
+ | `orderBy(col, dir?)` | Sort by column (`ASC` / `DESC`) |
174
+ | `limit(n)` | Max rows to return |
175
+ | `offset(n)` | Skip rows |
176
+ | `with(...relations)` | **No-op** — see known limitations |
177
+ | `first()` | First matching row or `null` |
178
+ | `find(id)` | Row by primary key or `null` |
179
+ | `get()` | All matching rows |
180
+ | `all()` | All rows in the table |
181
+ | `count()` | Row count matching current filters |
182
+ | `create(data)` | Insert a row, returns the inserted row |
183
+ | `update(id, data)` | Update by primary key, returns the updated row |
184
+ | `delete(id)` | Delete by primary key |
185
+ | `paginate(page, perPage?)` | Paginated result with metadata |
186
+
187
+ ---
188
+
189
+ ## Known Limitations
190
+
191
+ ### `with()` is a no-op
192
+
193
+ Drizzle relational queries require a fully pre-defined relation schema passed to the drizzle factory (`relations()` declarations). Because `adapter.query(tableName)` works with a dynamic string key, the adapter cannot access those pre-defined relations.
194
+
195
+ Use `with()` as a pass-through (it will silently be ignored) and load relations manually via separate queries when needed.
196
+
197
+ ### No MySQL support
198
+
199
+ `mysql2` does not support `.returning()`, which is required for `create()` and `update()`. MySQL support is not planned for v1.
200
+
201
+ ### `connect()` is a no-op
202
+
203
+ Drizzle establishes connections lazily on the first query. Calling `adapter.connect()` does nothing.
204
+
205
+ ### `disconnect()` — PostgreSQL only
206
+
207
+ For PostgreSQL, `disconnect()` ends the `postgres-js` connection pool via `$client.end()`. For SQLite and LibSQL, it is a no-op.
@@ -0,0 +1,20 @@
1
+ import type { OrmAdapterProvider } from '@boostkit/orm';
2
+ export declare class DrizzleTableRegistry {
3
+ private static tables;
4
+ static register(name: string, table: unknown): void;
5
+ static get(name: string): unknown | undefined;
6
+ }
7
+ export interface DrizzleConfig {
8
+ /** Pre-built drizzle db instance — skips driver setup */
9
+ client?: unknown;
10
+ /** Database driver. Defaults to 'sqlite' */
11
+ driver?: 'sqlite' | 'postgresql' | 'libsql';
12
+ /** Connection URL. Falls back to DATABASE_URL env var */
13
+ url?: string;
14
+ /** Map of table name → drizzle table schema object */
15
+ tables?: Record<string, unknown>;
16
+ /** Primary key column name. Defaults to 'id' */
17
+ primaryKey?: string;
18
+ }
19
+ export declare function drizzle(config?: DrizzleConfig): OrmAdapterProvider;
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,kBAAkB,EAMnB,MAAM,eAAe,CAAA;AAItB,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAC,MAAM,CAAkC;IAEvD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAInD,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;CAG9C;AAoPD,MAAM,WAAW,aAAa;IAC5B,yDAAyD;IACzD,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,QAAQ,CAAA;IAC3C,yDAAyD;IACzD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,wBAAgB,OAAO,CAAC,MAAM,GAAE,aAAkB,GAAG,kBAAkB,CAMtE"}
package/dist/index.js ADDED
@@ -0,0 +1,233 @@
1
+ import { eq, ne, gt, gte, lt, lte, like, inArray, notInArray, and, asc, desc, count as sqlCount, } from 'drizzle-orm';
2
+ // ─── Global Table Registry ─────────────────────────────────
3
+ export class DrizzleTableRegistry {
4
+ static tables = new Map();
5
+ static register(name, table) {
6
+ this.tables.set(name, table);
7
+ }
8
+ static get(name) {
9
+ return this.tables.get(name);
10
+ }
11
+ }
12
+ // ─── Drizzle Query Builder ─────────────────────────────────
13
+ class DrizzleQueryBuilder {
14
+ db;
15
+ table;
16
+ primaryKey;
17
+ _wheres = [];
18
+ _orders = [];
19
+ _limitN = null;
20
+ _offsetN = null;
21
+ constructor(db, table, primaryKey) {
22
+ this.db = db;
23
+ this.table = table;
24
+ this.primaryKey = primaryKey;
25
+ }
26
+ where(column, operatorOrValue, value) {
27
+ if (value === undefined) {
28
+ this._wheres.push({ column, operator: '=', value: operatorOrValue });
29
+ }
30
+ else {
31
+ this._wheres.push({ column, operator: operatorOrValue, value });
32
+ }
33
+ return this;
34
+ }
35
+ orWhere(column, value) {
36
+ this._wheres.push({ column, operator: '=', value });
37
+ return this;
38
+ }
39
+ orderBy(column, direction = 'ASC') {
40
+ this._orders.push({ column, direction });
41
+ return this;
42
+ }
43
+ limit(n) { this._limitN = n; return this; }
44
+ offset(n) { this._offsetN = n; return this; }
45
+ // Drizzle relational queries require pre-defined relation schemas — no-op here
46
+ with(..._relations) { return this; }
47
+ col(column) {
48
+ return this.table[column];
49
+ }
50
+ buildConditions() {
51
+ if (!this._wheres.length)
52
+ return undefined;
53
+ const exprs = this._wheres.map(clause => {
54
+ const col = this.col(clause.column);
55
+ switch (clause.operator) {
56
+ case '=': return eq(col, clause.value);
57
+ case '!=': return ne(col, clause.value);
58
+ case '>': return gt(col, clause.value);
59
+ case '>=': return gte(col, clause.value);
60
+ case '<': return lt(col, clause.value);
61
+ case '<=': return lte(col, clause.value);
62
+ case 'LIKE': return like(col, clause.value);
63
+ case 'IN': return inArray(col, clause.value);
64
+ case 'NOT IN': return notInArray(col, clause.value);
65
+ }
66
+ });
67
+ return exprs.length === 1 ? exprs[0] : and(...exprs);
68
+ }
69
+ buildOrderBy() {
70
+ return this._orders.map(o => {
71
+ const col = this.col(o.column);
72
+ return o.direction === 'DESC' ? desc(col) : asc(col);
73
+ });
74
+ }
75
+ async first() {
76
+ const db = this.db;
77
+ const cond = this.buildConditions();
78
+ const orderBy = this.buildOrderBy();
79
+ let q = db.select().from(this.table);
80
+ if (cond)
81
+ q = q.where(cond);
82
+ if (orderBy.length)
83
+ q = q.orderBy(...orderBy);
84
+ q = q.limit(1);
85
+ const result = await q;
86
+ return result[0] ?? null;
87
+ }
88
+ async find(id) {
89
+ const db = this.db;
90
+ const pkCol = this.col(this.primaryKey);
91
+ const result = await db
92
+ .select()
93
+ .from(this.table)
94
+ .where(eq(pkCol, id))
95
+ .limit(1);
96
+ return result[0] ?? null;
97
+ }
98
+ async get() {
99
+ const db = this.db;
100
+ const cond = this.buildConditions();
101
+ const orderBy = this.buildOrderBy();
102
+ let q = db.select().from(this.table);
103
+ if (cond)
104
+ q = q.where(cond);
105
+ if (orderBy.length)
106
+ q = q.orderBy(...orderBy);
107
+ if (this._limitN !== null)
108
+ q = q.limit(this._limitN);
109
+ if (this._offsetN !== null)
110
+ q = q.offset(this._offsetN);
111
+ return q;
112
+ }
113
+ async all() {
114
+ return this.db.select().from(this.table);
115
+ }
116
+ async count() {
117
+ const db = this.db;
118
+ const cond = this.buildConditions();
119
+ let q = db.select({ value: sqlCount() }).from(this.table);
120
+ if (cond)
121
+ q = q.where(cond);
122
+ const result = await q;
123
+ return Number(result[0]?.value ?? 0);
124
+ }
125
+ async create(data) {
126
+ const result = await this.db
127
+ .insert(this.table)
128
+ .values(data)
129
+ .returning();
130
+ return result[0];
131
+ }
132
+ async update(id, data) {
133
+ const pkCol = this.col(this.primaryKey);
134
+ const result = await this.db
135
+ .update(this.table)
136
+ .set(data)
137
+ .where(eq(pkCol, id))
138
+ .returning();
139
+ return result[0];
140
+ }
141
+ async delete(id) {
142
+ const pkCol = this.col(this.primaryKey);
143
+ await this.db
144
+ .delete(this.table)
145
+ .where(eq(pkCol, id));
146
+ }
147
+ async paginate(page = 1, perPage = 15) {
148
+ const cond = this.buildConditions();
149
+ const orderBy = this.buildOrderBy();
150
+ const db = this.db;
151
+ let pageQ = db.select().from(this.table);
152
+ let cntQ = db.select({ value: sqlCount() }).from(this.table);
153
+ if (cond) {
154
+ pageQ = pageQ.where(cond);
155
+ cntQ = cntQ.where(cond);
156
+ }
157
+ if (orderBy.length)
158
+ pageQ = pageQ.orderBy(...orderBy);
159
+ pageQ = pageQ.limit(perPage).offset((page - 1) * perPage);
160
+ const [data, countResult] = await Promise.all([pageQ, cntQ]);
161
+ const total = Number(countResult[0]?.value ?? 0);
162
+ const lastPage = Math.max(1, Math.ceil(total / perPage));
163
+ return {
164
+ data,
165
+ total,
166
+ perPage,
167
+ currentPage: page,
168
+ lastPage,
169
+ from: (page - 1) * perPage + 1,
170
+ to: Math.min(page * perPage, total),
171
+ };
172
+ }
173
+ }
174
+ // ─── Drizzle Adapter ───────────────────────────────────────
175
+ class DrizzleAdapter {
176
+ db;
177
+ tables;
178
+ primaryKey;
179
+ constructor(db, tables, primaryKey) {
180
+ this.db = db;
181
+ this.tables = tables;
182
+ this.primaryKey = primaryKey;
183
+ }
184
+ static async make(config) {
185
+ let db = config.client;
186
+ if (!db) {
187
+ const url = config.url ?? process.env['DATABASE_URL'] ?? 'file:./dev.db';
188
+ const driver = config.driver ?? 'sqlite';
189
+ if (driver === 'postgresql') {
190
+ const { default: postgres } = await import('postgres');
191
+ const { drizzle: dzPostgres } = await import('drizzle-orm/postgres-js');
192
+ db = dzPostgres(postgres(url));
193
+ }
194
+ else if (driver === 'libsql') {
195
+ const { createClient } = await import('@libsql/client');
196
+ const { drizzle: dzLibsql } = await import('drizzle-orm/libsql');
197
+ db = dzLibsql(createClient({ url }));
198
+ }
199
+ else {
200
+ // default: SQLite via better-sqlite3
201
+ const { default: Database } = await import('better-sqlite3');
202
+ const { drizzle: dzSqlite } = await import('drizzle-orm/better-sqlite3');
203
+ db = dzSqlite(new Database(url.replace(/^file:/, '')));
204
+ }
205
+ }
206
+ return new DrizzleAdapter(db, config.tables ?? {}, config.primaryKey ?? 'id');
207
+ }
208
+ query(table) {
209
+ const schema = this.tables[table] ?? DrizzleTableRegistry.get(table);
210
+ if (!schema) {
211
+ throw new Error(`[BoostKit ORM Drizzle] No table schema registered for "${table}". ` +
212
+ `Pass tables: { ${table}: myTable } in drizzle() config or call ` +
213
+ `DrizzleTableRegistry.register("${table}", myTable).`);
214
+ }
215
+ return new DrizzleQueryBuilder(this.db, schema, this.primaryKey);
216
+ }
217
+ async connect() {
218
+ // Drizzle connects lazily on first query — no-op
219
+ }
220
+ async disconnect() {
221
+ const end = this.db?.$client?.end;
222
+ if (typeof end === 'function')
223
+ await end();
224
+ }
225
+ }
226
+ export function drizzle(config = {}) {
227
+ return {
228
+ async create() {
229
+ return DrizzleAdapter.make(config);
230
+ },
231
+ };
232
+ }
233
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EACnD,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,IAAI,QAAQ,GAClC,MAAM,aAAa,CAAA;AAWpB,8DAA8D;AAE9D,MAAM,OAAO,oBAAoB;IACvB,MAAM,CAAC,MAAM,GAAyB,IAAI,GAAG,EAAE,CAAA;IAEvD,MAAM,CAAC,QAAQ,CAAC,IAAY,EAAE,KAAc;QAC1C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IAC9B,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;;AAGH,8DAA8D;AAE9D,MAAM,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ACd,MAAM,GAAG,GAAI,IAAI,CAAC,EAAU,EAAE,OAAO,EAAE,GAAG,CAAA;QAC1C,IAAI,OAAO,GAAG,KAAK,UAAU;YAAE,MAAM,GAAG,EAAE,CAAA;IAC5C,CAAC;CACF;AAiBD,MAAM,UAAU,OAAO,CAAC,SAAwB,EAAE;IAChD,OAAO;QACL,KAAK,CAAC,MAAM;YACV,OAAO,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACpC,CAAC;KACF,CAAA;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@boostkit/orm-drizzle",
3
+ "version": "0.0.1",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/boostkitjs/boostkit",
8
+ "directory": "packages/orm-drizzle"
9
+ },
10
+ "type": "module",
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "import": "./dist/index.js",
19
+ "default": "./dist/index.js",
20
+ "types": "./dist/index.d.ts"
21
+ }
22
+ },
23
+ "dependencies": {
24
+ "drizzle-orm": "^0.38.0",
25
+ "@boostkit/orm": "0.0.1"
26
+ },
27
+ "optionalDependencies": {
28
+ "better-sqlite3": "^12.0.0",
29
+ "@libsql/client": "^0.15.0",
30
+ "postgres": "^3.0.0"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^20.0.0",
34
+ "@types/better-sqlite3": "^7.0.0",
35
+ "typescript": "^5.4.0"
36
+ },
37
+ "scripts": {
38
+ "build": "tsc",
39
+ "dev": "tsc --watch",
40
+ "typecheck": "tsc --noEmit",
41
+ "clean": "rm -rf dist"
42
+ }
43
+ }