-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
populate.d.ts
41 lines (38 loc) · 1.38 KB
/
populate.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
declare module 'mongoose' {
/**
* Reference another Model
*/
type PopulatedDoc<
PopulatedType,
RawId extends RefType = (PopulatedType extends { _id?: RefType; } ? NonNullable<PopulatedType['_id']> : Types.ObjectId) | undefined
> = PopulatedType | RawId;
interface PopulateOptions {
/** space delimited path(s) to populate */
path: string;
/** fields to select */
select?: any;
/** query conditions to match */
match?: any;
/** optional model to use for population */
model?: string | Model<any>;
/** optional query options like sort, limit, etc */
options?: QueryOptions;
/** correct limit on populated array */
perDocumentLimit?: number;
/** optional boolean, set to `false` to allow populating paths that aren't in the schema */
strictPopulate?: boolean;
/** deep populate */
populate?: string | PopulateOptions | (string | PopulateOptions)[];
/**
* If true Mongoose will always set `path` to a document or `null`.
* If false Mongoose will always set `path` to a potentially empty array.
* Inferred from schema by default.
*/
justOne?: boolean;
/** transform function to call on every populated doc */
transform?: (doc: any, id: any) => any;
}
interface PopulateOption {
populate?: string | string[] | PopulateOptions | PopulateOptions[];
}
}