Models: add automatic created_at property value

This commit is contained in:
Alice Gaudon 2020-08-28 14:16:25 +02:00
parent f47f01f147
commit 5bcc63a62c

View File

@ -127,6 +127,9 @@ export default abstract class Model {
private async saveTransaction(connection: Connection, exists: boolean, needs_full_update: boolean): Promise<boolean> {
// Before save
await this.beforeSave(exists, connection);
if (!exists && this.hasOwnProperty('created_at')) {
this.created_at = new Date();
}
if (exists && this.hasOwnProperty('updated_at')) {
this.updated_at = new Date();
}