Skip to content

Bug: Model.ReplaceOne() fails to update timestamps #7152

Closed
@teddis

Description

@teddis

I'm using replaceOne() for the first time and timestamps are being stripped and not added to the document even though the Schema specifies the timestamps property:

 await RestModel.replaceOne({_id: rest.id}, rest.toObject()).exec();

I would expect Mongoose/MongoDB to respect this setting and properly update createdAt and updatedAt fields.

Using Mongoose 5.3.4, MongoDB 3.6.6, Typegoose 5.4.1, Typescript 3.1.1, and Node 10.11.0 on Mac OS X Mojave.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugWe've confirmed this is a bug in Mongoose and will fix it.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions