@housekit/orm 0.1.3 → 0.1.4
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/dist/relational.d.ts +39 -11
- package/package.json +1 -1
package/dist/relational.d.ts
CHANGED
|
@@ -1,33 +1,61 @@
|
|
|
1
1
|
import { type TableDefinition } from './core';
|
|
2
2
|
import type { SQLExpression } from './expressions';
|
|
3
3
|
/**
|
|
4
|
-
* Join strategy for relational queries
|
|
4
|
+
* Join strategy for relational queries.
|
|
5
|
+
*
|
|
6
|
+
* ClickHouse performance varies significantly depending on the join strategy used,
|
|
7
|
+
* especially in distributed environments.
|
|
5
8
|
*/
|
|
6
9
|
export type JoinStrategy = 'auto' | 'standard' | 'global' | 'any' | 'global_any';
|
|
10
|
+
/**
|
|
11
|
+
* Configuration options for the Relational Query API (`findMany`, `findFirst`).
|
|
12
|
+
*/
|
|
7
13
|
export type RelationalFindOptions<TTable = any> = {
|
|
14
|
+
/**
|
|
15
|
+
* Filter conditions for the main query.
|
|
16
|
+
* Can be a SQL expression or a callback receiving the table columns.
|
|
17
|
+
*
|
|
18
|
+
* @example where: (users) => eq(users.active, true)
|
|
19
|
+
*/
|
|
8
20
|
where?: SQLExpression | ((columns: TTable extends TableDefinition<infer TCols> ? TCols : any) => SQLExpression);
|
|
21
|
+
/**
|
|
22
|
+
* Maximum number of records to return from the primary table.
|
|
23
|
+
*/
|
|
9
24
|
limit?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Number of records to skip from the primary table.
|
|
27
|
+
*/
|
|
10
28
|
offset?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Nested relations to include in the result set.
|
|
31
|
+
* Set to `true` for all columns or provide a `RelationalFindOptions` object for nested filtering/limiting.
|
|
32
|
+
*
|
|
33
|
+
* @example with: { posts: { limit: 5 }, profile: true }
|
|
34
|
+
*/
|
|
11
35
|
with?: Record<string, boolean | RelationalFindOptions>;
|
|
12
36
|
/**
|
|
13
37
|
* Join strategy for related data.
|
|
14
38
|
*
|
|
15
|
-
* - 'auto': Automatically uses GLOBAL when table has onCluster option
|
|
16
|
-
* - 'standard': Regular LEFT JOIN
|
|
17
|
-
* - 'global': Force GLOBAL JOIN (for clusters)
|
|
18
|
-
* - 'any': Use ANY JOIN (faster,
|
|
19
|
-
* - 'global_any': Combine GLOBAL and ANY
|
|
39
|
+
* - 'auto': Automatically uses GLOBAL when table has onCluster option.
|
|
40
|
+
* - 'standard': Regular LEFT JOIN.
|
|
41
|
+
* - 'global': Force GLOBAL JOIN (for sharded clusters).
|
|
42
|
+
* - 'any': Use ANY JOIN (faster, optimized for 1:1 relations).
|
|
43
|
+
* - 'global_any': Combine GLOBAL and ANY.
|
|
20
44
|
*
|
|
21
45
|
* @default 'auto'
|
|
22
46
|
*/
|
|
23
47
|
joinStrategy?: JoinStrategy;
|
|
24
48
|
};
|
|
25
49
|
/**
|
|
26
|
-
* Build a modern relational API with ClickHouse optimizations.
|
|
50
|
+
* Build a modern relational API with ClickHouse-specific optimizations.
|
|
51
|
+
*
|
|
52
|
+
* Key architectural features:
|
|
53
|
+
* - **groupUniqArray Optimization**: Instead of flat-joining which causes row explosion,
|
|
54
|
+
* HouseKit uses ClickHouse aggregation to fetch nested relations as arrays of tuples.
|
|
55
|
+
* - **Automatic Cluster Handling**: Detects sharded tables and applies GLOBAL JOINs.
|
|
56
|
+
* - **Smart Deduplication**: Merges results in-memory when flat joins are unavoidable.
|
|
27
57
|
*
|
|
28
|
-
*
|
|
29
|
-
* -
|
|
30
|
-
* - Join strategy selection for performance tuning
|
|
31
|
-
* - Support for dictionary lookups as alternative to JOINs
|
|
58
|
+
* @param client - The ClickHouse client instance.
|
|
59
|
+
* @param schema - The shared schema definition containing all table and relation metadata.
|
|
32
60
|
*/
|
|
33
61
|
export declare function buildRelationalAPI(client: any, schema?: Record<string, TableDefinition<any>>): Record<string, any> | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@housekit/orm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
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",
|