Skip to content

Commit

Permalink
types(model): add missing function signature for model() to match `…
Browse files Browse the repository at this point in the history
…$model()` re: #13963
  • Loading branch information
vkarpov15 committed Oct 11, 2023
1 parent 430f7ad commit 46a6ecc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/types/document.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ function gh13878() {
const User = model('User', schema);
const user = new User({ name: 'John', age: 30 });
expectType<typeof User>(user.$model());
expectType<typeof User>(user.model());
}

function gh13094() {
Expand Down
4 changes: 4 additions & 0 deletions types/document.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ declare module 'mongoose' {
markModified<T extends keyof DocType>(path: T, scope?: any): void;
markModified(path: string, scope?: any): void;

/** Returns the model with the given name on this document's associated connection. */
model<ModelType = Model<unknown>>(name: string): ModelType;
model<ModelType = Model<DocType>>(): ModelType;

/** Returns the list of paths that have been modified. */
modifiedPaths(options?: { includeChildren?: boolean }): Array<string>;

Expand Down

0 comments on commit 46a6ecc

Please sign in to comment.