Skip to content

Commit 87bc411

Browse files
committed
fix(index.d.ts): allow passing options to model() in place of removed skipInit
Fix #11137
1 parent fd1abea commit 87bc411

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

index.d.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,21 @@ declare module 'mongoose' {
114114
/** Gets mongoose options */
115115
export function get<K extends keyof MongooseOptions>(key: K): MongooseOptions[K];
116116

117+
/*! ignore */
118+
type CompileModelOptions = { overwriteModels?: boolean, connection?: Connection };
119+
117120
/**
118121
* Returns true if Mongoose can cast the given value to an ObjectId, or
119122
* false otherwise.
120123
*/
121124
export function isValidObjectId(v: any): boolean;
122125

123-
export function model<T>(name: string, schema?: Schema<T, any, any> | Schema<T & Document, any, any>, collection?: string, skipInit?: boolean): Model<T>;
126+
export function model<T>(name: string, schema?: Schema<T, any, any> | Schema<T & Document, any, any>, collection?: string, options?: CompileModelOptions): Model<T>;
124127
export function model<T, U, TQueryHelpers = {}>(
125128
name: string,
126129
schema?: Schema<T, U, TQueryHelpers>,
127130
collection?: string,
128-
skipInit?: boolean
131+
options?: CompileModelOptions
129132
): U;
130133

131134
/** Returns an array of model names created on this instance of Mongoose. */
@@ -371,12 +374,12 @@ declare module 'mongoose' {
371374
models: { [index: string]: Model<any> };
372375

373376
/** Defines or retrieves a model. */
374-
model<T>(name: string, schema?: Schema<any>, collection?: string): Model<T>;
377+
model<T>(name: string, schema?: Schema<any>, collection?: string, options?: CompileModelOptions): Model<T>;
375378
model<T, U, TQueryHelpers = {}>(
376379
name: string,
377380
schema?: Schema<T, U, TQueryHelpers>,
378381
collection?: string,
379-
skipInit?: boolean
382+
options?: CompileModelOptions
380383
): U;
381384

382385
/** Returns an array of model names created on this connection. */

0 commit comments

Comments
 (0)