diff --git a/backend/src/controllers/appControllers/clientController/summary.js b/backend/src/controllers/appControllers/clientController/summary.js index 087d7461f..0fb8f869e 100644 --- a/backend/src/controllers/appControllers/clientController/summary.js +++ b/backend/src/controllers/appControllers/clientController/summary.js @@ -39,7 +39,7 @@ const summary = async (Model, req, res) => { { $match: { removed: false, - created: { $gte: startDate.toDate(), $lte: endDate.toDate() }, + createdAt: { $gte: startDate.toDate(), $lte: endDate.toDate() }, enabled: true, }, }, diff --git a/backend/src/controllers/appControllers/paymentController/update.js b/backend/src/controllers/appControllers/paymentController/update.js index 0691048eb..441f95f89 100644 --- a/backend/src/controllers/appControllers/paymentController/update.js +++ b/backend/src/controllers/appControllers/paymentController/update.js @@ -44,7 +44,6 @@ const update = async (req, res) => { ? 'partially' : 'unpaid'; - const updatedDate = new Date(); const updates = { number: req.body.number, date: req.body.date, @@ -52,7 +51,6 @@ const update = async (req, res) => { paymentMode: req.body.paymentMode, ref: req.body.ref, description: req.body.description, - updated: updatedDate, }; const result = await Model.findOneAndUpdate( diff --git a/backend/src/controllers/coreControllers/settingController/listAll.js b/backend/src/controllers/coreControllers/settingController/listAll.js index a3d0561f5..7bb2e78c0 100644 --- a/backend/src/controllers/coreControllers/settingController/listAll.js +++ b/backend/src/controllers/coreControllers/settingController/listAll.js @@ -8,7 +8,7 @@ const listAll = async (req, res) => { const result = await Model.find({ removed: false, isPrivate: false, - }).sort({ created: sort }); + }).sort({ createdAt: sort }); if (result.length > 0) { return res.status(200).json({ diff --git a/backend/src/controllers/middlewaresControllers/createCRUDController/listAll.js b/backend/src/controllers/middlewaresControllers/createCRUDController/listAll.js index 699d80380..d8f42ef10 100644 --- a/backend/src/controllers/middlewaresControllers/createCRUDController/listAll.js +++ b/backend/src/controllers/middlewaresControllers/createCRUDController/listAll.js @@ -9,7 +9,7 @@ const listAll = async (Model, req, res) => { result = await Model.find({ removed: false, }) - .sort({ created: sort }) + .sort({ createdAt: sort }) .populate() .exec(); } else { @@ -17,7 +17,7 @@ const listAll = async (Model, req, res) => { removed: false, enabled: enabled, }) - .sort({ created: sort }) + .sort({ createdAt: sort }) .populate() .exec(); } diff --git a/backend/src/models/appModels/Client.js b/backend/src/models/appModels/Client.js index f8407a89f..6751f90b3 100644 --- a/backend/src/models/appModels/Client.js +++ b/backend/src/models/appModels/Client.js @@ -20,15 +20,7 @@ const schema = new mongoose.Schema({ email: String, createdBy: { type: mongoose.Schema.ObjectId, ref: 'Admin' }, assigned: { type: mongoose.Schema.ObjectId, ref: 'Admin' }, - created: { - type: Date, - default: Date.now, - }, - updated: { - type: Date, - default: Date.now, - }, -}); +}, {timestamps: true}); schema.plugin(require('mongoose-autopopulate')); diff --git a/backend/src/models/appModels/Invoice.js b/backend/src/models/appModels/Invoice.js index 9858557c3..1aa9006fd 100644 --- a/backend/src/models/appModels/Invoice.js +++ b/backend/src/models/appModels/Invoice.js @@ -164,16 +164,8 @@ const invoiceSchema = new mongoose.Schema({ default: true, }, }, - ], - updated: { - type: Date, - default: Date.now, - }, - created: { - type: Date, - default: Date.now, - }, -}); + ] +}, { timestamps: true }); invoiceSchema.plugin(require('mongoose-autopopulate')); module.exports = mongoose.model('Invoice', invoiceSchema); diff --git a/backend/src/models/appModels/Payment.js b/backend/src/models/appModels/Payment.js index c884b653d..2f0721522 100644 --- a/backend/src/models/appModels/Payment.js +++ b/backend/src/models/appModels/Payment.js @@ -49,14 +49,6 @@ const paymentSchema = new mongoose.Schema({ description: { type: String, }, - updated: { - type: Date, - default: Date.now, - }, - created: { - type: Date, - default: Date.now, - }, -}); +}, { timestamps: true }); paymentSchema.plugin(require('mongoose-autopopulate')); module.exports = mongoose.model('Payment', paymentSchema); diff --git a/backend/src/models/appModels/PaymentMode.js b/backend/src/models/appModels/PaymentMode.js index e7bd85268..83c5a0dae 100644 --- a/backend/src/models/appModels/PaymentMode.js +++ b/backend/src/models/appModels/PaymentMode.js @@ -25,10 +25,6 @@ const paymentModeSchema = new mongoose.Schema({ type: Boolean, default: false, }, - created: { - type: Date, - default: Date.now, - }, -}); +}, {timestamps: true}); module.exports = mongoose.model('PaymentMode', paymentModeSchema); diff --git a/backend/src/models/appModels/Quote.js b/backend/src/models/appModels/Quote.js index 8cdd2a5ba..6c1a2ce3c 100644 --- a/backend/src/models/appModels/Quote.js +++ b/backend/src/models/appModels/Quote.js @@ -127,15 +127,7 @@ const quoteSchema = new mongoose.Schema({ }, }, ], - updated: { - type: Date, - default: Date.now, - }, - created: { - type: Date, - default: Date.now, - }, -}); +}, {timestamps: true}); quoteSchema.plugin(require('mongoose-autopopulate')); module.exports = mongoose.model('Quote', quoteSchema); diff --git a/backend/src/models/appModels/Taxes.js b/backend/src/models/appModels/Taxes.js index 8e600c10c..ed5735bea 100644 --- a/backend/src/models/appModels/Taxes.js +++ b/backend/src/models/appModels/Taxes.js @@ -22,10 +22,6 @@ const schema = new mongoose.Schema({ type: Boolean, default: false, }, - created: { - type: Date, - default: Date.now, - }, -}); +}, {timestamps: true}); module.exports = mongoose.model('Taxes', schema); diff --git a/backend/src/models/coreModels/Admin.js b/backend/src/models/coreModels/Admin.js index 5b06abae0..423de2de7 100644 --- a/backend/src/models/coreModels/Admin.js +++ b/backend/src/models/coreModels/Admin.js @@ -23,15 +23,11 @@ const adminSchema = new Schema({ type: String, trim: true, }, - created: { - type: Date, - default: Date.now, - }, role: { type: String, default: 'owner', enum: ['owner'], }, -}); +}, {timestamps: true}); module.exports = mongoose.model('Admin', adminSchema); diff --git a/backend/src/models/coreModels/AdminPassword.js b/backend/src/models/coreModels/AdminPassword.js index 06594558a..699021993 100644 --- a/backend/src/models/coreModels/AdminPassword.js +++ b/backend/src/models/coreModels/AdminPassword.js @@ -31,7 +31,7 @@ const AdminPasswordSchema = new Schema({ type: [String], default: [], }, -}); +},{timestamps: true}); // AdminPasswordSchema.index({ user: 1 }); // generating a hash diff --git a/backend/src/models/coreModels/Upload.js b/backend/src/models/coreModels/Upload.js index 78c31c1a7..b458ee4d4 100644 --- a/backend/src/models/coreModels/Upload.js +++ b/backend/src/models/coreModels/Upload.js @@ -64,10 +64,6 @@ const uploadSchema = new mongoose.Schema({ type: String, required: true, }, - created: { - type: Date, - default: Date.now, - }, -}); +}, {timestamps: true}); module.exports = mongoose.model('Upload ', uploadSchema); diff --git a/frontend/src/components/UpdateForm/index.jsx b/frontend/src/components/UpdateForm/index.jsx index 5345543d1..9b6972616 100644 --- a/frontend/src/components/UpdateForm/index.jsx +++ b/frontend/src/components/UpdateForm/index.jsx @@ -63,16 +63,16 @@ export default function UpdateForm({ config, formElements, withUpload = false }) expiredDate: dayjs(newValues['expiredDate']).format('YYYY-MM-DDTHH:mm:ss.SSSZ'), }; } - if (newValues.created) { + if (newValues.createdAt) { newValues = { ...newValues, - created: dayjs(newValues['created']).format('YYYY-MM-DDTHH:mm:ss.SSSZ'), + createdAt: dayjs(newValues['createdAt']).format('YYYY-MM-DDTHH:mm:ss.SSSZ'), }; } - if (newValues.updated) { + if (newValues.updatedAt) { newValues = { ...newValues, - updated: dayjs(newValues['updated']).format('YYYY-MM-DDTHH:mm:ss.SSSZ'), + updatedAt: dayjs(newValues['updatedAt']).format('YYYY-MM-DDTHH:mm:ss.SSSZ'), }; } form.resetFields();