@hemia/db-connector 0.0.7 → 0.0.8
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.
|
@@ -120,13 +120,18 @@ class ClickHouseConnector extends OLAPConnector {
|
|
|
120
120
|
}
|
|
121
121
|
insert(options) {
|
|
122
122
|
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
123
|
+
try {
|
|
124
|
+
const client = this.ensureClient();
|
|
125
|
+
const { table, values, format = 'JSONEachRow' } = options;
|
|
126
|
+
return yield client.insert({
|
|
127
|
+
table,
|
|
128
|
+
values: values,
|
|
129
|
+
format: format,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
130
135
|
});
|
|
131
136
|
}
|
|
132
137
|
find(table_1) {
|
|
@@ -120,13 +120,18 @@ class ClickHouseConnector extends OLAPConnector {
|
|
|
120
120
|
}
|
|
121
121
|
insert(options) {
|
|
122
122
|
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
123
|
+
try {
|
|
124
|
+
const client = this.ensureClient();
|
|
125
|
+
const { table, values, format = 'JSONEachRow' } = options;
|
|
126
|
+
return yield client.insert({
|
|
127
|
+
table,
|
|
128
|
+
values: values,
|
|
129
|
+
format: format,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
130
135
|
});
|
|
131
136
|
}
|
|
132
137
|
find(table_1) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { InsertResult } from '@clickhouse/client';
|
|
1
2
|
import { CredentialsConnection } from '../types/CredentialsConnection';
|
|
2
3
|
import { OLAPConnector, InsertOptions, ClickHouseInsertFormat } from '../abstract/OLAPConnector';
|
|
3
4
|
export declare class ClickHouseConnector extends OLAPConnector {
|
|
@@ -10,6 +11,6 @@ export declare class ClickHouseConnector extends OLAPConnector {
|
|
|
10
11
|
disconnect(): Promise<void>;
|
|
11
12
|
isConnected(): Promise<boolean>;
|
|
12
13
|
query<T = unknown>(sql: string): Promise<T[]>;
|
|
13
|
-
insert<F extends ClickHouseInsertFormat = 'JSONEachRow'>(options: InsertOptions<F>): Promise<
|
|
14
|
+
insert<F extends ClickHouseInsertFormat = 'JSONEachRow'>(options: InsertOptions<F>): Promise<InsertResult>;
|
|
14
15
|
find<T = unknown>(table: string, filters?: Record<string, any>): Promise<T[]>;
|
|
15
16
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { InsertResult } from "@clickhouse/client";
|
|
1
2
|
export type ClickHouseInsertFormat = 'JSONEachRow' | 'JSON' | 'JSONCompactEachRow' | 'CSV' | 'TabSeparated' | 'TabSeparatedWithNames' | 'Values';
|
|
2
3
|
export type ClickHouseInsertValues<T> = T extends 'JSONEachRow' | 'JSONCompactEachRow' | 'JSON' ? Record<string, any>[] : string;
|
|
3
4
|
export interface InsertOptions<F extends ClickHouseInsertFormat = 'JSONEachRow'> {
|
|
@@ -10,6 +11,6 @@ export declare abstract class OLAPConnector {
|
|
|
10
11
|
abstract disconnect(): Promise<void>;
|
|
11
12
|
abstract isConnected(): Promise<boolean>;
|
|
12
13
|
abstract query<T = unknown>(sql: string): Promise<T[]>;
|
|
13
|
-
abstract insert<F extends ClickHouseInsertFormat = 'JSONEachRow'>(options: InsertOptions<F>): Promise<
|
|
14
|
+
abstract insert<F extends ClickHouseInsertFormat = 'JSONEachRow'>(options: InsertOptions<F>): Promise<InsertResult>;
|
|
14
15
|
abstract find<T = unknown>(table: string, filters: Record<string, any>): Promise<T[]>;
|
|
15
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hemia/db-connector",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Hemia Database Conector",
|
|
5
5
|
"main": "dist/hemia-db-connector.js",
|
|
6
6
|
"module": "dist/hemia-db-connector.esm.js",
|
|
@@ -74,4 +74,4 @@
|
|
|
74
74
|
"files": [
|
|
75
75
|
"dist"
|
|
76
76
|
]
|
|
77
|
-
}
|
|
77
|
+
}
|