Skip to content

Commit

Permalink
Merge pull request #11439 from hiukky/patch-1
Browse files Browse the repository at this point in the history
chore: update declarations for schema options
  • Loading branch information
AbdelrahmanHafez committed Feb 21, 2022
2 parents f2eb071 + c26ff4e commit 98ed1e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/types/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,16 @@ function gh10789() {
required: true
}
});
}

function gh11439() {
type Book = {
collection: string
}

const bookSchema = new Schema<Book>({
collection: String
}, {
supressReservedKeysWarning: true
});
}
7 changes: 7 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,13 @@ declare module 'mongoose' {
* field names by setting timestamps.createdAt and timestamps.updatedAt.
*/
timestamps?: boolean | SchemaTimestampsConfig;

/**
* Using `save`, `isNew`, and other Mongoose reserved names as schema path names now triggers a warning, not an error.
* You can suppress the warning by setting { supressReservedKeysWarning: true } schema options. Keep in mind that this
* can break plugins that rely on these reserved names.
*/
supressReservedKeysWarning?: boolean
}

interface SchemaTimestampsConfig {
Expand Down

0 comments on commit 98ed1e5

Please sign in to comment.