/
mongoose.d.ts
43 lines (38 loc) · 982 Bytes
/
mongoose.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { Model, Schema, Document } from 'mongoose';
export interface PaginateOptions {
select?: object | string;
sort?: object | string;
populate?: Array<object> | Array<string> | object | string;
lean?: boolean;
leanWithId?: boolean;
offset?: number;
page?: number;
limit?: number;
}
export interface PaginateResult<T> {
docs: Array<T>;
total: number;
limit: number;
page?: number;
pages?: number;
offset?: number;
}
export interface PaginateModel<T extends Document> extends Model<T> {
paginate(
query?: object,
options?: PaginateOptions,
callback?: (err: any, result: PaginateResult<T>) => void,
): Promise<PaginateResult<T>>;
}
export function model<T extends Document>(
name: string,
schema?: Schema,
collection?: string,
skipInit?: boolean,
): PaginateModel<T>;
export function model<T extends Document, U extends PaginateModel<T>>(
name: string,
schema?: Schema,
collection?: string,
skipInit?: boolean,
): U;