@housekit/orm 0.1.40 → 0.1.42
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/index.js +6 -19
- package/dist/utils/background-batcher.d.ts +0 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4557,22 +4557,9 @@ class BackgroundBatcher {
|
|
|
4557
4557
|
queues = new Map;
|
|
4558
4558
|
timers = new Map;
|
|
4559
4559
|
tables = new Map;
|
|
4560
|
-
serializers = new Map;
|
|
4561
4560
|
constructor(client) {
|
|
4562
4561
|
this.client = client;
|
|
4563
4562
|
}
|
|
4564
|
-
getSerializer(table) {
|
|
4565
|
-
const tableName = table.$table;
|
|
4566
|
-
if (!this.serializers.has(tableName)) {
|
|
4567
|
-
const config = Object.values(table.$columns).map((col) => ({
|
|
4568
|
-
name: col.name,
|
|
4569
|
-
type: col.type,
|
|
4570
|
-
isNullable: col.isNull
|
|
4571
|
-
}));
|
|
4572
|
-
this.serializers.set(tableName, new SyncBinarySerializer(config));
|
|
4573
|
-
}
|
|
4574
|
-
return this.serializers.get(tableName);
|
|
4575
|
-
}
|
|
4576
4563
|
async add(table, row, config) {
|
|
4577
4564
|
const tableName = table.$table;
|
|
4578
4565
|
if (!this.queues.has(tableName)) {
|
|
@@ -4607,20 +4594,20 @@ class BackgroundBatcher {
|
|
|
4607
4594
|
const dataToInsert = [...queue];
|
|
4608
4595
|
this.queues.set(tableName, []);
|
|
4609
4596
|
try {
|
|
4610
|
-
const serializer = this.getSerializer(table);
|
|
4611
|
-
const binaryBuffer = serializer.serialize(dataToInsert);
|
|
4612
4597
|
const { Readable } = await import("stream");
|
|
4613
|
-
const
|
|
4598
|
+
const stream = Readable.from(dataToInsert, { objectMode: true });
|
|
4614
4599
|
await this.client.insert({
|
|
4615
4600
|
table: tableName,
|
|
4616
|
-
values:
|
|
4617
|
-
format: "
|
|
4601
|
+
values: stream,
|
|
4602
|
+
format: "JSONEachRow",
|
|
4618
4603
|
clickhouse_settings: {
|
|
4619
4604
|
async_insert: 1,
|
|
4620
4605
|
wait_for_async_insert: 0
|
|
4621
4606
|
}
|
|
4622
4607
|
});
|
|
4623
|
-
} catch (err) {
|
|
4608
|
+
} catch (err) {
|
|
4609
|
+
console.error(`[housekit] Background flush failed for ${tableName}:`, err);
|
|
4610
|
+
}
|
|
4624
4611
|
}
|
|
4625
4612
|
async flushAll() {
|
|
4626
4613
|
const promises = [];
|
|
@@ -9,9 +9,7 @@ declare class BackgroundBatcher {
|
|
|
9
9
|
private queues;
|
|
10
10
|
private timers;
|
|
11
11
|
private tables;
|
|
12
|
-
private serializers;
|
|
13
12
|
constructor(client: ClickHouseClient);
|
|
14
|
-
private getSerializer;
|
|
15
13
|
add(table: TableRuntime<any, any>, row: any, config: BatchConfig): Promise<void>;
|
|
16
14
|
flush(tableName: string): Promise<void>;
|
|
17
15
|
flushAll(): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@housekit/orm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.42",
|
|
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",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@clickhouse/client": "^1.0.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@clickhouse/client": "^1.
|
|
58
|
+
"@clickhouse/client": "^1.15.0",
|
|
59
59
|
"@types/uuid": "^11.0.0",
|
|
60
60
|
"typescript": "^5.0.0"
|
|
61
61
|
},
|