question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CreateDateColumn doesn't work with mongodb and default values

See original GitHub issue

Issue 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:open
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sedgwickzcommented, Dec 2, 2020

Using this way below probably help you a bit. It works for me.

 @Column()
  title: string = 'hello';
1reaction
imnotjamescommented, Sep 26, 2020

Every other driver in typeorm should support these features. Postgres is one of those.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found