Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(schemaoptions.d.ts): add option "overwriteModels" as a schema option #12817

Merged
merged 1 commit into from Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions test/types/schema.test.ts
Expand Up @@ -978,3 +978,7 @@ function gh12782() {
test: string
}>({} as Props);
}

function gh12816() {
const schema = new Schema({}, { overwriteModels: true });
}
6 changes: 6 additions & 0 deletions types/schemaoptions.d.ts
Expand Up @@ -213,6 +213,12 @@ declare module 'mongoose' {
* Virtual paths.
*/
virtuals?: SchemaOptionsVirtualsPropertyType<DocType, TVirtuals, TInstanceMethods>,

/**
* Set to `true` to default to overwriting models with the same name when calling `mongoose.model()`, as opposed to throwing an `OverwriteModelError`.
* @default false
*/
overwriteModels?: boolean;
}

interface DefaultSchemaOptions {
Expand Down