Models: add automatic created_at property value
This commit is contained in:
parent
f47f01f147
commit
5bcc63a62c
@ -127,6 +127,9 @@ export default abstract class Model {
|
|||||||
private async saveTransaction(connection: Connection, exists: boolean, needs_full_update: boolean): Promise<boolean> {
|
private async saveTransaction(connection: Connection, exists: boolean, needs_full_update: boolean): Promise<boolean> {
|
||||||
// Before save
|
// Before save
|
||||||
await this.beforeSave(exists, connection);
|
await this.beforeSave(exists, connection);
|
||||||
|
if (!exists && this.hasOwnProperty('created_at')) {
|
||||||
|
this.created_at = new Date();
|
||||||
|
}
|
||||||
if (exists && this.hasOwnProperty('updated_at')) {
|
if (exists && this.hasOwnProperty('updated_at')) {
|
||||||
this.updated_at = new Date();
|
this.updated_at = new Date();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user