@gftdcojp/gftd-orm
Version:
Enterprise-grade real-time data platform with ksqlDB, inspired by Supabase architecture
130 lines • 3.32 kB
TypeScript
/**
* クライアントサイド用Database Module
*/
import { KsqlDbConfig, SchemaRegistryConfig } from './types';
import { KsqlDbClientBrowser } from './http-client';
export interface DatabaseClientConfig {
ksql: KsqlDbConfig;
schemaRegistry: SchemaRegistryConfig;
}
/**
* クライアントサイド用Database クラス
*/
export declare class DatabaseClient {
private config;
private ksqlClient;
private initialized;
constructor(config: DatabaseClientConfig);
/**
* データベースを初期化
*/
initialize(): Promise<void>;
/**
* テーブルからデータを取得(Supabaseライク)
*/
from<T = any>(table: string): DatabaseClientQueryBuilder<T>;
/**
* SQL文を直接実行
*/
sql(query: string, params?: any[]): Promise<any>;
/**
* ヘルスチェック
*/
health(): Promise<{
status: 'ok' | 'error';
details?: any;
}>;
}
/**
* クライアントサイド用クエリビルダー
*/
export declare class DatabaseClientQueryBuilder<T = any> {
protected tableName: string;
protected ksqlClient: KsqlDbClientBrowser;
protected selectFields: string[];
protected whereConditions: any;
protected orderByConditions: any;
protected limitValue?: number;
protected offsetValue?: number;
constructor(tableName: string, ksqlClient: KsqlDbClientBrowser);
/**
* 選択するフィールドを指定
*/
select(fields?: string): this;
/**
* WHERE条件を追加
*/
eq(column: string, value: any): this;
/**
* LIKE条件を追加
*/
like(column: string, pattern: string): this;
/**
* 範囲条件を追加
*/
gte(column: string, value: any): this;
lte(column: string, value: any): this;
gt(column: string, value: any): this;
lt(column: string, value: any): this;
/**
* IN条件を追加
*/
in(column: string, values: any[]): this;
/**
* ORDER BY を追加
*/
order(column: string, ascending?: boolean): this;
/**
* LIMIT を設定
*/
limit(count: number): this;
/**
* OFFSET を設定
*/
offset(count: number): this;
/**
* クエリを実行してデータを取得
*/
execute(): Promise<{
data: T[];
error?: any;
}>;
/**
* 単一レコードを取得
*/
single(): Promise<{
data: T | null;
error?: any;
}>;
/**
* データを挿入(Supabaseライク)
*/
insert(values: Partial<T>): Promise<{
data: T | null;
error?: any;
}>;
/**
* データを更新(Supabaseライク)
*/
update(values: Partial<T>): Promise<{
data: T[];
error?: any;
}>;
/**
* データを削除(Supabaseライク)
*/
delete(): Promise<{
data: any;
error?: any;
}>;
private buildSelectQuery;
private formatValue;
private buildInsertQuery;
private buildUpdateQuery;
private buildDeleteQuery;
}
/**
* クライアントサイド用データベースインスタンスを作成
*/
export declare function createDatabaseClient(config: DatabaseClientConfig): DatabaseClient;
//# sourceMappingURL=database-client.d.ts.map