helene
Version:
Real-time Web Apps for Node.js
28 lines (27 loc) • 1.01 kB
TypeScript
import { BaseDocument, Collection } from './collection';
export type Query = {
[key: string]: any;
};
export type SortQuery = {
[key: string]: 1 | -1;
};
export type Projection = {
[key: string]: 0 | 1;
};
export declare class Cursor<T extends BaseDocument = BaseDocument> implements PromiseLike<T[]> {
db: Collection;
query: Query;
_limit: number;
_skip: number;
_sort: SortQuery;
_projection: Projection;
constructor(db: Collection, query?: Query);
limit(limit: number): this;
skip(skip: number): this;
sort(sortQuery: SortQuery): this;
projection(projection: Projection): this;
project(candidates: T[]): any[];
exec(): Promise<T[]>;
map(fn: (item: T) => Promise<any> | any): Promise<any[]>;
then<TResult1 = T[], TResult2 = never>(onfulfilled?: ((value: T[]) => PromiseLike<TResult1> | TResult1) | undefined | null, onrejected?: ((reason: any) => PromiseLike<TResult2> | TResult2) | undefined | null): PromiseLike<TResult1 | TResult2>;
}