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

Use Mongoose timestamps option to automatically handle createdAt and updatedAt fields #1207

Open
katiyarkartik0 opened this issue Jan 14, 2025 · 1 comment

Comments

@katiyarkartik0
Copy link

In MongoDB with Mongoose, you do not need to manually create a createdAt field if you're using Mongoose's built-in timestamps option. This option automatically adds createdAt and updatedAt fields to your schema.

By setting the timestamps option to true in the schema, Mongoose will automatically handle the createdAt and updatedAt fields for you.

At backend/src/models/coreModels, backend/src/models/appModels/Client.js, backend/src/controllers/appControllers/clientController/summary.js, backend/src/models/appModels/Invoice.js, backend/src/models/appModels/Payment.js, backend/src/models/appModels/PaymentMode.js, backend/src/models/appModels/Quote.js, backend/src/models/appModels/Taxes.js, backend/src/models/coreModels/Admin.js , backend/src/models/coreModels/Upload.js we can see the explicit declaration of created field.

We shall use timestamp boolean instead.

@katiyarkartik0
Copy link
Author

Please assign this issue to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant