Aleksandar Pavić
Aleksandar Pavić

Reputation: 3420

How to change field names of timestamps in sequelize

I need to change default timestamp createdAt and modifiedAt field names for model in sequelize.

They should just be changed to created and modified.

I know that I should be able to disable timestamps, then use custom-ones, but I'm not trying to do that I want to override/change default behavior of timestams, because of built-in functionality.

And I can't find it anywhere in sequelize doc.

Upvotes: 0

Views: 816

Answers (1)

Anatoly
Anatoly

Reputation: 22758

You can do this, see this example:

// model definition
...
// model options
{
    tableName: 'my_table',
    createdAt: 'created',
    updatedAt: 'modified',
    schema: 'public'
}

Upvotes: 1

Related Questions