@housekit/orm 0.1.26 → 0.1.28

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 CHANGED
@@ -178,15 +178,22 @@ await db.insert(events).values([
178
178
 
179
179
  ### JSON Insert with Returning
180
180
 
181
- Use `.returning()` when you need the inserted data back:
181
+ Use `.returningOne()` for single inserts or `.returning()` for multiple:
182
182
 
183
183
  ```typescript
184
- const [user] = await db
184
+ // Single insert
185
+ const user = await db
185
186
  .insert(users)
186
187
  .values({ email: 'a@b.com', role: 'admin' })
187
- .returning();
188
+ .returningOne();
188
189
 
189
190
  console.log(user.id); // Generated UUID
191
+
192
+ // Multiple inserts
193
+ const [user1, user2] = await db
194
+ .insert(users)
195
+ .values([{ email: 'a@b.com' }, { email: 'b@c.com' }])
196
+ .returning();
190
197
  ```
191
198
 
192
199
  ### Force JSON Format
@@ -34,7 +34,19 @@ export declare class ClickHouseInsertBuilder<TTable extends TableRuntime<any, an
34
34
  values(value: CleanInsert<TTable> | Array<CleanInsert<TTable>> | Iterable<CleanInsert<TTable>> | AsyncIterable<CleanInsert<TTable>> | Readable): ClickHouseInsertBuilder<TTable, TReturn>;
35
35
  /** @template [T = CleanInsert<TTable>] */
36
36
  insert(data: CleanInsert<TTable> | CleanInsert<TTable>[]): Promise<TReturn>;
37
+ /**
38
+ * Return inserted data as an array.
39
+ * Use when inserting multiple rows.
40
+ */
37
41
  returning(): ClickHouseInsertBuilder<TTable, CleanSelect<TTable>[]>;
42
+ /**
43
+ * Return the single inserted row directly (not wrapped in array).
44
+ * Use when inserting a single value for cleaner syntax.
45
+ *
46
+ * @example
47
+ * const user = await db.insert(users).values({ email: 'a@b.com' }).returningOne();
48
+ */
49
+ returningOne(): ClickHouseInsertBuilder<TTable, CleanSelect<TTable>>;
38
50
  /**
39
51
  * Disable the default returning() behavior.
40
52
  * Useful when you don't need the inserted data back and want to avoid the overhead.
package/dist/index.js CHANGED
@@ -4707,6 +4707,11 @@ class ClickHouseInsertBuilder {
4707
4707
  this._returning = true;
4708
4708
  return this;
4709
4709
  }
4710
+ returningOne() {
4711
+ this._returning = true;
4712
+ this._isSingle = true;
4713
+ return this;
4714
+ }
4710
4715
  noReturning() {
4711
4716
  this._returning = false;
4712
4717
  return this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@housekit/orm",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "description": "Type-safe ClickHouse ORM with modern DX and ClickHouse-specific optimizations. Features Turbo Mode (RowBinary), full engine support, and advanced query capabilities.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",