dla
Version:
node.js data loader with caching and support of lists
25 lines (24 loc) • 750 B
TypeScript
import { Cache } from './cache';
import * as Types from './shared-types';
export declare class Collection<V> implements Types.ICollection<V> {
protected extractId: Types.IdExtractor<V>;
/**
* External cache wrapper
*/
protected objectCache: Cache<Types.ICacheElement<V>>;
/**
* Cache of objects requested during collection life
*/
protected promiseCache: {
[id: string]: Promise<V>;
};
private loadFew;
private query;
constructor(options: Types.ICollectionOptions<V>);
getOne(id: string): Promise<V>;
getFewAsArray(ids: string[]): Promise<V[]>;
getFewAsMap(ids: string[]): Promise<{
[key: string]: V;
}>;
clearCache(idS: string | string[]): Promise<void>;
}