When working with NestJS and Mongoose, one commonly used feature is the timestamps
option in schemas, which automatically manages createdAt
and updatedAt
fields. By default, Mongoose uses camelCase (createdAt
, updatedAt
) for these fields. However, you might need to follow a different naming convention, such as snake_case (created_at
, updated_at
), to align with your database's naming standards or project guidelines.
In this article, we'll explore how to customize these keys in a NestJS Mongoose schema.