database.do
Version:
AI-Native Data Access SDK for seamless database operations
47 lines (46 loc) • 1.49 kB
TypeScript
export interface ClientOptions {
baseUrl?: string;
apiKey?: string;
headers?: Record<string, string>;
}
export interface ErrorResponse {
errors?: Array<{
message: string;
code?: string;
path?: string;
}>;
}
export interface ListResponse<T> {
data: T[];
meta?: {
total?: number;
page?: number;
pageSize?: number;
hasNextPage?: boolean;
};
}
export interface QueryParams {
[key: string]: any;
limit?: number;
page?: number;
sort?: string | string[];
where?: Record<string, any>;
}
export declare class ApiClient {
private baseUrl;
private headers;
constructor(options?: ClientOptions);
private request;
get<T>(path: string, params?: QueryParams): Promise<T>;
post<T>(path: string, data: any): Promise<T>;
put<T>(path: string, data: any): Promise<T>;
patch<T>(path: string, data: any): Promise<T>;
delete<T>(path: string): Promise<T>;
list<T>(collection: string, params?: QueryParams): Promise<ListResponse<T>>;
getById<T>(collection: string, id: string): Promise<T>;
create<T>(collection: string, data: Partial<T>): Promise<T>;
update<T>(collection: string, id: string, data: Partial<T>): Promise<T>;
replace<T>(collection: string, id: string, data: T): Promise<T>;
remove<T>(collection: string, id: string): Promise<T>;
search<T>(collection: string, query: string, params?: QueryParams): Promise<ListResponse<T>>;
}