Typeorm: CreateDateColumn but with int type instead of date

Viewed 310

As far as I've read in the docs, to automatically update the date when the row is created we use @CreateDateColumn() when initializing entity. They've also mentioned to use Date type as the type of column.
But the mysql database table I'm trying to create entity of, uses time_add column as follows:

time_add INT(10) NOT NULL DEFAULT '0',

And I don't have the authority to change any of it's predefined properties.

I'm creating the entity like this:

    @CreateDateColumn({
        type: "timestamp", length: 10,
        nullable: false,
        default: 0
    })
    time_add!: Date | number;

Here's the problem and my question:
Do I need to set the column type to int instead? and what do I do so it queries actual timestamp number instead of it's usual Date format which is a string which also contains timezone etc info too? and do I need to mention the length of that column while mentioning it's type to be timestamp? My question extends to @UpdateDateColumn() as well in this database every time column is set to INT(10)

I typed this in a bit of a hurry I hope I was clear enough. Thanks

0 Answers
Related