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(types): allow using an object to configure timestamps #12061

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
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