UNPKG

rollun-ts-datastore-test

Version:

rollun-datastore written in TS

27 lines (26 loc) 960 B
import { DataStoreInterface, HttpClientInterface } from './interfaces'; import { Query } from 'rollun-ts-rql-test'; import { AxiosResponse } from 'axios'; export interface HttpDataStoreOptions { client?: HttpClientInterface; idField?: string; timeout?: number; headers?: { [key: string]: string; }; } export default class HttpDatastore<T = any> implements DataStoreInterface<T> { readonly identifier: any; protected readonly timeout: number; private url; constructor(url: string, { idField, timeout, headers }?: HttpDataStoreOptions); read(id: string): Promise<T>; has(id: string): Promise<boolean>; query<U = T>(query?: Query): Promise<Array<U>>; create(item: Partial<T>): Promise<T>; update(item: Partial<T>): Promise<T>; delete(id: string): Promise<T>; count(): Promise<number>; rewrite(item: Partial<T>): Promise<T>; protected getItemCount(response: AxiosResponse): number; }