Skip to content

Commit 46a6ecc

Browse files
committed
types(model): add missing function signature for model() to match $model() re: #13963
1 parent 430f7ad commit 46a6ecc

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

test/types/document.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ function gh13878() {
302302
const User = model('User', schema);
303303
const user = new User({ name: 'John', age: 30 });
304304
expectType<typeof User>(user.$model());
305+
expectType<typeof User>(user.model());
305306
}
306307

307308
function gh13094() {

types/document.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ declare module 'mongoose' {
192192
markModified<T extends keyof DocType>(path: T, scope?: any): void;
193193
markModified(path: string, scope?: any): void;
194194

195+
/** Returns the model with the given name on this document's associated connection. */
196+
model<ModelType = Model<unknown>>(name: string): ModelType;
197+
model<ModelType = Model<DocType>>(): ModelType;
198+
195199
/** Returns the list of paths that have been modified. */
196200
modifiedPaths(options?: { includeChildren?: boolean }): Array<string>;
197201

0 commit comments

Comments
 (0)