@housekit/orm 0.1.48 → 0.1.49

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 +86 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,16 +2,17 @@
2
2
 
3
3
  **The high-performance, type-safe ClickHouse ORM for Node.js and Bun.**
4
4
 
5
- > ⚠️ **Public Beta**: This package is currently in public beta. Feedback is highly appreciated as we polish the API for v1.0.
5
+ > ⚠️ **Public Beta**: This package is currently in public beta. Feedback is highly appreciated as we polish API for v1.0.
6
6
 
7
- > 💡 **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).
7
+ > 💡 **Interactive Docs**: Use [RepoGrep](https://app.ami.dev/repogrep?repo=https://github.com/pablofdezr/housekit) to search and query entire codebase and documentation for free (Updated instantly).
8
8
 
9
- > 💡 **Ask ZRead**: Need deep insights? [Ask ZRead](https://zread.ai/pablofdezr/housekit) for AI-powered understanding of the codebase (Updated weekly).
9
+ > 💡 **Ask ZRead**: Need deep insights? [Ask ZRead](https://zread.ai/pablofdezr/housekit) for AI-powered understanding of codebase (Updated weekly).
10
10
 
11
- > 💡 **Ask Devin AI**: Have questions about integrating HouseKit? [Ask the Wiki](https://deepwiki.com/pablofdezr/housekit) for AI-powered assistance (Updated weekly).
11
+ > 💡 **Ask Devin AI**: Have questions about integrating HouseKit? [Ask Wiki](https://deepwiki.com/pablofdezr/housekit) for AI-powered assistance (Updated weekly).
12
12
 
13
- 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.
13
+ HouseKit ORM is a modern database toolkit designed specifically for ClickHouse. It bridges gap between ergonomic developer experiences and extreme performance requirements of high-volume OLAP workloads.
14
14
 
15
+ [![npm](https://nodei.co/npm/@housekit/orm.png)](https://www.npmjs.com/package/@housekit/orm)
15
16
  [![npm version](https://img.shields.io/npm/v/@housekit/orm.svg)](https://www.npmjs.com/package/@housekit/orm)
16
17
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
17
18
  [![Documentation](https://img.shields.io/badge/Docs-RepoGrep-teal?style=flat-square)](https://app.ami.dev/repogrep?repo=https://github.com/pablofdezr/housekit)
@@ -127,6 +128,86 @@ const [user] = await db
127
128
 
128
129
  ---
129
130
 
131
+ ## 🎯 The `housekit()` Client
132
+
133
+ The `housekit()` function creates a fully-featured ClickHouse client with query builders for all operations.
134
+
135
+ ### Client Methods
136
+
137
+ | Method | Description |
138
+ |--------|-------------|
139
+ | **`db.select()`** | Creates a SELECT query builder |
140
+ | **`db.insert(table)`** | Inserts data into a table |
141
+ | **`db.insertMany(table, data, opts)`** | Bulk inserts with configuration |
142
+ | **`db.update(table)`** | Updates rows in a table |
143
+ | **`db.delete(table)`** | Deletes rows from a table |
144
+ | **`db.raw(sql, params)`** | Executes raw SQL queries |
145
+ | **`db.command({query, query_params})`** | Executes ClickHouse commands |
146
+ | **`db.close()`** | Closes the connection |
147
+
148
+ ### Client Properties
149
+
150
+ | Property | Description |
151
+ |----------|-------------|
152
+ | **`db.rawClient`** | Raw `@clickhouse/client` instance (direct access) |
153
+ | **`db.query`** ⭐ | **Relational API** - only available if `{ schema }` is passed |
154
+ | **`db.schema`** | Your defined table schema |
155
+
156
+ ### ⭐ The Relational API (`db.query`)
157
+
158
+ **Only available when you pass a schema:**
159
+
160
+ ```typescript
161
+ const db = housekit({ url: 'http://localhost:8123' }, {
162
+ schema: { users, events }
163
+ });
164
+ ```
165
+
166
+ Then you can query using ORM-style methods:
167
+
168
+ ```typescript
169
+ // Find by ID
170
+ db.query.users.findById('uuid-here');
171
+
172
+ // Find many with conditions
173
+ db.query.users.findMany({ where: { role: 'admin' } });
174
+
175
+ // Find first with columns
176
+ db.query.users.findFirst({ columns: { id: true, email: true } });
177
+
178
+ // Find with relations (automatic JOIN)
179
+ db.query.users.findMany({
180
+ with: { posts: true }
181
+ });
182
+ ```
183
+
184
+ ### Complete Example
185
+
186
+ ```typescript
187
+ const db = housekit({ url: 'http://localhost:8123' }, { schema });
188
+
189
+ // 1. Insert using builder
190
+ await db.insert(schema.users).values({ email: 'a@b.com', role: 'admin' });
191
+
192
+ // 2. Regular SELECT
193
+ const result = await db.select().from(schema.users).where(eq(schema.users.role, 'admin'));
194
+
195
+ // 3. Relational query (automatic JOIN)
196
+ const user = await db.query.users.findById('uuid-here', {
197
+ with: { posts: true }
198
+ });
199
+
200
+ // 4. Raw SQL
201
+ const data = await db.raw('SELECT * FROM users LIMIT 10');
202
+
203
+ // 5. Close connection
204
+ await db.close();
205
+ ```
206
+
207
+ ---
208
+
209
+ ---
210
+
130
211
  ## 🔍 Relational Query API
131
212
 
132
213
  ### findMany / findFirst
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@housekit/orm",
3
- "version": "0.1.48",
3
+ "version": "0.1.49",
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",