Skip to content

Commit

Permalink
Differentiate between model/document and query populate options (Defi…
Browse files Browse the repository at this point in the history
  • Loading branch information
moraleja39 authored and RyanCavanaugh committed May 24, 2019
1 parent 11b0360 commit 7ff648e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions types/mongoose/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,7 @@ declare module "mongoose" {
*/
populate(path: string | any, select?: string | any, model?: any,
match?: any, options?: any): this;
populate(options: ModelPopulateOptions | ModelPopulateOptions[]): this;
populate(options: QueryPopulateOptions | QueryPopulateOptions[]): this;

/**
* Determines the MongoDB nodes from which to read.
Expand Down Expand Up @@ -3307,7 +3307,7 @@ declare module "mongoose" {
session?: ClientSession | null;
}

interface ModelPopulateOptions {
interface QueryPopulateOptions {
/** space delimited path(s) to populate */
path: string;
/** optional fields to select */
Expand All @@ -3319,7 +3319,12 @@ declare module "mongoose" {
/** optional query options like sort, limit, etc */
options?: any;
/** deep populate */
populate?: ModelPopulateOptions | ModelPopulateOptions[];
populate?: QueryPopulateOptions | QueryPopulateOptions[];
}

interface ModelPopulateOptions extends QueryPopulateOptions {
/** optional, if true Mongoose will always set path to an array. Inferred from schema by default */
justOne?: boolean;
}

interface ModelUpdateOptions extends ModelOptions {
Expand Down

0 comments on commit 7ff648e

Please sign in to comment.