You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)
I want to automatically populate the created_at and updated_at columns.
import {BaseEntity, CreateDateColumn, PrimaryGeneratedColumn, UpdateDateColumn} from "typeorm"
import {Moment} from "moment"
import {momentTransformer} from "../helpers/transformers"
export default abstract class Model extends BaseEntity {
@PrimaryGeneratedColumn()
id: number
@CreateDateColumn({type: "timestamp", transformer: momentTransformer})
created_at: Moment
@UpdateDateColumn({type: "timestamp", transformer: momentTransformer})
updated_at: Moment
}
How can I set a default value (current time) that is used for the sql query without altering the DB schema. I,e. I want the code to set the value and not the DB. The code above results in the following query:
INSERT INTO someTable(id, created_at, updated_at) VALUES (DEFAULT, DEFAULT, DEFAULT)
The text was updated successfully, but these errors were encountered:
Issue type:
[x] question
[ ] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ]
cordova
[ ]
mongodb
[ ]
mssql
[x]
mysql
/mariadb
[ ]
oracle
[ ]
postgres
[ ]
sqlite
[ ]
sqljs
[ ]
react-native
[ ]
expo
TypeORM version:
[x]
latest
[ ]
@next
[ ]
0.x.x
(or put your version here)I want to automatically populate the created_at and updated_at columns.
How can I set a default value (current time) that is used for the sql query without altering the DB schema. I,e. I want the code to set the value and not the DB. The code above results in the following query:
INSERT INTO
someTable(
id,
created_at,
updated_at) VALUES (DEFAULT, DEFAULT, DEFAULT)
The text was updated successfully, but these errors were encountered: