hagopj13 / node-express-boilerplate

A boilerplate for building production-ready RESTful APIs using Node.js, Express, and Mongoose
MIT License
6.89k stars 2.03k forks source link

Mongos timestamps absent from res json #80

Closed tevon456 closed 3 years ago

tevon456 commented 3 years ago

In the mongo models, I enabled the {timestamps: true} however when logging out the response the updatedAt and createdAt values are present but never come across in the JSON response to the client I'm not sure why this is also true for paginated responses as well.

hagopj13 commented 3 years ago

Hi @tevon456, that is because of the toJSON plugin that is being used with the model (for instance, userSchema.plugin(toJSON);). You can remove that, or modify the plugin itself to fit your needs.

tevon456 commented 3 years ago

Hey, @hagopj13 I just found it thanks for the quick response this solved my issue.