feat(core): introduce typed ClickHouse table API, query builder, and result handling; enhance HTTP client and add schema evolution, batch inserts and mutations; update docs/tests and bump deps

This commit is contained in:
2026-02-27 10:17:32 +00:00
parent 26449e9171
commit aace102868
17 changed files with 7000 additions and 1886 deletions

View File

@@ -0,0 +1,44 @@
import * as plugins from './smartclickhouse.plugins.js';
export class ClickhouseResultSet<T> {
public rows: T[];
public rowCount: number;
constructor(rows: T[]) {
this.rows = rows;
this.rowCount = rows.length;
}
public first(): T | null {
return this.rows.length > 0 ? this.rows[0] : null;
}
public last(): T | null {
return this.rows.length > 0 ? this.rows[this.rows.length - 1] : null;
}
public isEmpty(): boolean {
return this.rows.length === 0;
}
public toArray(): T[] {
return this.rows;
}
public map<U>(fn: (row: T) => U): U[] {
return this.rows.map(fn);
}
public filter(fn: (row: T) => boolean): ClickhouseResultSet<T> {
return new ClickhouseResultSet<T>(this.rows.filter(fn));
}
public toObservable(): plugins.smartrx.rxjs.Observable<T> {
return new plugins.smartrx.rxjs.Observable<T>((observer) => {
for (const row of this.rows) {
observer.next(row);
}
observer.complete();
});
}
}