CreateDateColumn doesn't work with mongodb and default values
See original GitHub issueIssue type:
CreateDateColumn doesn’t work with mongodb
[x ] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ x] mongodb
[ ] mssql
[ ] mysql
/ mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[ x] latest
[ ] @next
[ ] 0.x.x
(or put your version here)
Steps to reproduce or a small repository showing the problem:
@CreateDateColumn()
createdAt: string;
It doesn’t set anything
default values also don’t work
@Column({ default: "hello" })
title: string;
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Current date in TypeORM and PostgreSQL - Stack Overflow
Basically, the problem comes from using Date.now() instead of new Date() . My working example looks like this @Column({ type: "timestamptz" ...
Read more >Decorator reference | TypeORM Docs
Default value is true . select: boolean - Defines whether or not to hide this column by default when making queries. When set...
Read more >TypeORM MongoDB Review - Eliezer Steinbock - Medium
Default values don't work. You'll have to handle all values yourself when creating each object. Automatically adding createdAt and updatedAt fields is ...
Read more >typeorm/typeorm - Gitter
QueryFailedError: null value in column "createdAt" violates not-null constraint. I have added this code to my entities: @CreateDateColumn() public ...
Read more >TypeORM - Amazing ORM for TypeScript and JavaScript (ES7 ...
Database can be one of the following values: mysql , mariadb , postgres , cockroachdb , sqlite , mssql , sap , spanner...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Using this way below probably help you a bit. It works for me.
Every other driver in typeorm should support these features. Postgres is one of those.