@jokio/datastore
Version:
Helper library for Google Cloud Datastore
25 lines (24 loc) • 1.42 kB
TypeScript
/// <reference types="google-cloud__datastore" />
import * as Datastore from '@google-cloud/datastore';
import { OneOrMany, DatastoreKey } from '@google-cloud/datastore/entity';
import { CommitResponse } from '@google-cloud/datastore/request';
import { Query, QueryInfo, QueryOptions } from '@google-cloud/datastore/query';
import { Entity } from "./types";
export declare type QueryProcessor = (x: Query) => Query;
export declare abstract class DbSetBase<TEntity extends Entity> {
protected kind: string;
protected datastore: Datastore;
constructor(kind: string, datastore: Datastore);
protected abstract onSave(entities: OneOrMany<object>): Promise<CommitResponse | undefined>;
protected abstract onGet<TResult = any>(key: DatastoreKey, options?: QueryOptions): Promise<TResult | undefined>;
protected abstract onCreateQuery(kind: string): Query;
protected abstract onRunQuery<TResult = any>(query: Query, options?: QueryOptions): Promise<[TResult[], QueryInfo]>;
save(...items: TEntity[]): Promise<CommitResponse | undefined>;
saveAndGet(item: TEntity): Promise<TEntity>;
get(id: any): Promise<TEntity>;
query(queryProcessor?: (x: Query) => Query, options?: QueryOptions): Promise<TEntity[]>;
queryWithInfo(queryProcessor?: QueryProcessor, options?: QueryOptions): Promise<{
result: TEntity[];
queryInfo: QueryInfo;
}>;
}