@kozojs/db 0.1.4 → 0.1.5
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/README.md +59 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @kozojs/db
|
|
2
|
+
|
|
3
|
+
Drizzle ORM integration for [Kozo Framework](https://github.com/kozojs/kozo).
|
|
4
|
+
Supports PostgreSQL, MySQL, and SQLite with a single unified API.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install @kozojs/db drizzle-orm
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import { createDatabase } from '@kozojs/db';
|
|
16
|
+
import { createKozo } from '@kozojs/core';
|
|
17
|
+
|
|
18
|
+
const db = await createDatabase({
|
|
19
|
+
provider: 'postgresql',
|
|
20
|
+
url: process.env.DATABASE_URL,
|
|
21
|
+
schema: { users },
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const app = createKozo({ services: { db } });
|
|
25
|
+
|
|
26
|
+
app.get('/users', {}, (c) => c.services.db.query.users.findMany());
|
|
27
|
+
|
|
28
|
+
await app.nativeListen(3000);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Supported Providers
|
|
32
|
+
|
|
33
|
+
| Provider | Config |
|
|
34
|
+
|---|---|
|
|
35
|
+
| **PostgreSQL** | `{ provider: 'postgresql', url: 'postgres://...' }` |
|
|
36
|
+
| **MySQL** | `{ provider: 'mysql', url: 'mysql://...' }` |
|
|
37
|
+
| **SQLite** | `{ provider: 'sqlite', file: './db.sqlite' }` |
|
|
38
|
+
|
|
39
|
+
## Testing
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { createTestDatabase } from '@kozojs/db';
|
|
43
|
+
|
|
44
|
+
// In-memory SQLite — no setup needed
|
|
45
|
+
const db = createTestDatabase(schema);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Re-exports
|
|
49
|
+
|
|
50
|
+
All common Drizzle utilities are re-exported for convenience:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { sql, eq, and, or, desc, asc } from '@kozojs/db';
|
|
54
|
+
import { createInsertSchema, createSelectSchema } from '@kozojs/db';
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## License
|
|
58
|
+
|
|
59
|
+
MIT
|