@housekit/orm 0.1.45 → 0.1.46
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 +36 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,10 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
> ⚠️ **Public Beta**: This package is currently in public beta. Feedback is highly appreciated as we polish the API for v1.0.
|
|
6
6
|
|
|
7
|
+
> [!TIP]
|
|
8
|
+
> **Interactive Docs**: Use [RepoGrep](https://app.ami.dev/repogrep?repo=https://github.com/pablofdezr/housekit) to search and query the entire codebase and documentation for free (Updated instantly).
|
|
9
|
+
|
|
10
|
+
> [!TIP]
|
|
11
|
+
> **Ask ZRead**: Need deep insights? [Ask ZRead](https://zread.ai/pablofdezr/housekit) for AI-powered understanding of the codebase (Updated weekly).
|
|
12
|
+
|
|
13
|
+
> [!TIP]
|
|
14
|
+
> **Ask Devin AI**: Have questions about integrating HouseKit? [Ask the Wiki](https://deepwiki.com/pablofdezr/housekit) for AI-powered assistance (Updated weekly).
|
|
15
|
+
|
|
7
16
|
HouseKit ORM is a modern database toolkit designed specifically for ClickHouse. It bridges the gap between ergonomic developer experiences and the extreme performance requirements of high-volume OLAP workloads.
|
|
8
17
|
|
|
9
18
|
[](https://www.npmjs.com/package/@housekit/orm)
|
|
10
19
|
[](https://opensource.org/licenses/MIT)
|
|
20
|
+
[](https://app.ami.dev/repogrep?repo=https://github.com/pablofdezr/housekit)
|
|
21
|
+
[](https://zread.ai/pablofdezr/housekit)
|
|
22
|
+
[](https://deepwiki.com/pablofdezr/housekit)
|
|
23
|
+
[](https://www.morphllm.com/playground/na/warpgrep?repo=pablofdezr%2Fhousekit)
|
|
11
24
|
|
|
12
25
|
---
|
|
13
26
|
|
|
@@ -39,7 +52,7 @@ bun add @housekit/orm @clickhouse/client
|
|
|
39
52
|
import { defineTable, t, Engine, relations } from '@housekit/orm';
|
|
40
53
|
|
|
41
54
|
export const users = defineTable('users', {
|
|
42
|
-
id: t.uuid('id').autoGenerate({ version: 7 }).primaryKey()
|
|
55
|
+
id: t.uuid('id').autoGenerate({ version: 7 }).primaryKey(),
|
|
43
56
|
email: t.string('email'),
|
|
44
57
|
role: t.enum('role', ['admin', 'user']),
|
|
45
58
|
...t.timestamps(),
|
|
@@ -49,7 +62,7 @@ export const users = defineTable('users', {
|
|
|
49
62
|
});
|
|
50
63
|
|
|
51
64
|
export const posts = defineTable('posts', {
|
|
52
|
-
id: t.uuid('id').autoGenerate({ version: 7 }).primaryKey()
|
|
65
|
+
id: t.uuid('id').autoGenerate({ version: 7 }).primaryKey(),
|
|
53
66
|
userId: t.uuid('user_id'),
|
|
54
67
|
title: t.string('title'),
|
|
55
68
|
createdAt: t.timestamp('created_at').default('now()'),
|
|
@@ -66,6 +79,27 @@ export type User = typeof users.$type;
|
|
|
66
79
|
export type NewUser = typeof users.$insert;
|
|
67
80
|
```
|
|
68
81
|
|
|
82
|
+
#### UUID Generation Options
|
|
83
|
+
|
|
84
|
+
HouseKit supports two approaches for UUID generation:
|
|
85
|
+
|
|
86
|
+
| Approach | Method | When to Use |
|
|
87
|
+
|----------|--------|-------------|
|
|
88
|
+
| **Client-side** | `.autoGenerate({ version: 7 })` | When using `.returning()` or `.returningOne()` |
|
|
89
|
+
| **Server-side** | `.default('generateUUIDv7()')` | When you don't need the ID back immediately |
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
// Client-side generation (recommended for most cases)
|
|
93
|
+
// UUID is generated in JS before insert, works with returning()
|
|
94
|
+
id: t.uuid('id').autoGenerate({ version: 7 }).primaryKey()
|
|
95
|
+
|
|
96
|
+
// Server-side generation
|
|
97
|
+
// UUID is generated by ClickHouse, cannot use returning()
|
|
98
|
+
id: t.uuid('id').primaryKey().default('generateUUIDv7()')
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Note:** Don't combine both - it's redundant. Choose one based on whether you need `.returning()` support.
|
|
102
|
+
|
|
69
103
|
### 2. Connect and Query
|
|
70
104
|
|
|
71
105
|
```typescript
|
package/dist/index.js
CHANGED
|
@@ -6245,14 +6245,14 @@ var windowFns = { over, rowNumber, rank, denseRank, lag, lead };
|
|
|
6245
6245
|
// src/schema-builder.ts
|
|
6246
6246
|
function primaryUuid(name) {
|
|
6247
6247
|
const colName = name ?? "id";
|
|
6248
|
-
const column = new ClickHouseColumn(colName, "UUID").autoGenerate().primaryKey()
|
|
6248
|
+
const column = new ClickHouseColumn(colName, "UUID").autoGenerate().primaryKey();
|
|
6249
6249
|
return {
|
|
6250
6250
|
[colName]: column
|
|
6251
6251
|
};
|
|
6252
6252
|
}
|
|
6253
6253
|
function primaryUuidV7(name) {
|
|
6254
6254
|
const colName = name ?? "id";
|
|
6255
|
-
const column = new ClickHouseColumn(colName, "UUID").autoGenerate({ version: 7 }).primaryKey()
|
|
6255
|
+
const column = new ClickHouseColumn(colName, "UUID").autoGenerate({ version: 7 }).primaryKey();
|
|
6256
6256
|
return {
|
|
6257
6257
|
[colName]: column
|
|
6258
6258
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@housekit/orm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.46",
|
|
4
4
|
"description": "Type-safe ClickHouse ORM with modern DX and ClickHouse-specific optimizations. Features optimized JSONCompact streaming, full engine support, and advanced query capabilities.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|