Skip to content

Commit

Permalink
Merge pull request #12061 from lantw44/wip/lantw/fix(types)-allow-usi…
Browse files Browse the repository at this point in the history
…ng-an-object-to-configure-timestamps

fix(types): allow using an object to configure timestamps
  • Loading branch information
vkarpov15 committed Jul 7, 2022
2 parents e324006 + 19b6d4a commit 7e09c9b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion types/models.d.ts
Expand Up @@ -106,7 +106,7 @@ declare module 'mongoose' {
checkKeys?: boolean;
j?: boolean;
safe?: boolean | WriteConcern;
timestamps?: boolean;
timestamps?: boolean | QueryTimestampsConfig;
validateBeforeSave?: boolean;
validateModifiedOnly?: boolean;
w?: number | string;
Expand Down
7 changes: 6 additions & 1 deletion types/query.d.ts
Expand Up @@ -90,6 +90,11 @@ declare module 'mongoose' {
[key: string]: any;
};

interface QueryTimestampsConfig {
createdAt?: boolean;
updatedAt?: boolean;
}

interface QueryOptions<DocType = unknown> extends
PopulateOption,
SessionOption {
Expand Down Expand Up @@ -157,7 +162,7 @@ declare module 'mongoose' {
* skip timestamps for this update. Note that this allows you to overwrite
* timestamps. Does nothing if schema-level timestamps are not set.
*/
timestamps?: boolean;
timestamps?: boolean | QueryTimestampsConfig;
upsert?: boolean;
writeConcern?: mongodb.WriteConcern;

Expand Down

0 comments on commit 7e09c9b

Please sign in to comment.