inversify-datastore
Version:
Some utilities for the development of Google Cloud Datastore applications using Inversify
39 lines (38 loc) • 2.05 kB
TypeScript
import { interfaces } from "./interfaces";
import { Datastore } from "@google-cloud/datastore";
import { Namespaced, PagedResponse, QueryRequest } from "./types";
import { RunQueryResponse } from "@google-cloud/datastore/build/src/query";
import PagedCrudRepository = interfaces.PagedCrudRepository;
export declare class BaseRepository<T> implements interfaces.CrudRepository<T> {
protected _db: Datastore;
private readonly _entityIdentifier;
constructor(datastore: Datastore);
exists(id: any, ns?: Namespaced): Promise<boolean>;
exists(queryRequest?: QueryRequest): Promise<boolean>;
findAll(queryRequest?: QueryRequest): Promise<T[]>;
findAllById(ids: any[], ns?: Namespaced): Promise<T[]>;
findById(id: any, ns?: Namespaced): Promise<T>;
save(t: T, ns?: Namespaced): Promise<T>;
saveAll(ts: T[], ns?: Namespaced): Promise<T[]>;
remove(t: T, ns?: Namespaced): Promise<boolean>;
remove(id: any, ns?: Namespaced): Promise<boolean>;
removeAll(entities: T[], ns?: Namespaced): Promise<boolean>;
removeAll(ids: any[], ns?: Namespaced): Promise<boolean>;
count(queryRequest?: QueryRequest): Promise<number>;
protected createQuery(queryRequest?: QueryRequest): import("@google-cloud/datastore/build/src/query").Query;
protected createKey(kind: string, key: any, ns?: Namespaced): import("@google-cloud/datastore/build/src/entity").entity.Key;
protected mapData(t: T, ns?: Namespaced): Promise<EntityRequest>;
protected createKeys(kind: string, keys: any[], ns?: Namespaced): import("@google-cloud/datastore/build/src/entity").entity.Key[];
protected kind(): string;
protected findAllKeys(queryRequest?: QueryRequest): Promise<RunQueryResponse>;
}
export declare class PagedBaseRepository<T> extends BaseRepository<T> implements PagedCrudRepository<T> {
findAllPaged(queryRequest?: QueryRequest): Promise<PagedResponse<T>>;
}
interface EntityRequest {
key: any;
data: any;
excludeFromIndexes: string[];
excludeLargeProperties: boolean;
}
export {};