1 | declare module 'mongoose' {
|
2 |
|
3 | /**
|
4 | * Reference another Model
|
5 | */
|
6 | type PopulatedDoc<
|
7 | PopulatedType,
|
8 | RawId extends RefType = (PopulatedType extends { _id?: RefType; } ? NonNullable<PopulatedType['_id']> : Types.ObjectId) | undefined
|
9 | > = PopulatedType | RawId;
|
10 |
|
11 | interface PopulateOptions {
|
12 | /** space delimited path(s) to populate */
|
13 | path: string;
|
14 | /** fields to select */
|
15 | select?: any;
|
16 | /** query conditions to match */
|
17 | match?: any;
|
18 | /** optional model to use for population */
|
19 | model?: string | Model<any>;
|
20 | /** optional query options like sort, limit, etc */
|
21 | options?: QueryOptions;
|
22 | /** correct limit on populated array */
|
23 | perDocumentLimit?: number;
|
24 | /** optional boolean, set to `false` to allow populating paths that aren't in the schema */
|
25 | strictPopulate?: boolean;
|
26 | /** deep populate */
|
27 | populate?: string | PopulateOptions | (string | PopulateOptions)[];
|
28 | /**
|
29 | * If true Mongoose will always set `path` to a document, or `null` if no document was found.
|
30 | * If false Mongoose will always set `path` to an array, which will be empty if no documents are found.
|
31 | * Inferred from schema by default.
|
32 | */
|
33 | justOne?: boolean;
|
34 | /** transform function to call on every populated doc */
|
35 | transform?: (doc: any, id: any) => any;
|
36 | /** Overwrite the schema-level local field to populate on if this is a populated virtual. */
|
37 | localField?: string;
|
38 | /** Overwrite the schema-level foreign field to populate on if this is a populated virtual. */
|
39 | foreignField?: string;
|
40 | }
|
41 |
|
42 | interface PopulateOption {
|
43 | populate?: string | string[] | PopulateOptions | PopulateOptions[];
|
44 | }
|
45 | }
|