From e0760a78b2ac2998844d986cfc1d17b085c26376 Mon Sep 17 00:00:00 2001 From: xmlking Date: Sat, 12 Jan 2019 13:55:24 -0800 Subject: [PATCH] fix(api): using timestamptz type for Dates in Entities --- apps/api/src/app/auth/user.entity.ts | 4 ++-- apps/api/src/app/core/entities/audit-base.entity.ts | 4 ++-- .../src/app/notifications/notification/notification.entity.ts | 4 ++-- .../src/app/notifications/subscription/subscription.entity.ts | 4 ++-- libs/ngx-utils/package.json | 2 +- .../src/lib/pipes/date-fns/format-time-in-words.pipe.ts | 4 ---- 6 files changed, 9 insertions(+), 13 deletions(-) diff --git a/apps/api/src/app/auth/user.entity.ts b/apps/api/src/app/auth/user.entity.ts index b3032f3a4..0b5038e78 100644 --- a/apps/api/src/app/auth/user.entity.ts +++ b/apps/api/src/app/auth/user.entity.ts @@ -41,10 +41,10 @@ export class User extends Base { @Column() userId: string; - @CreateDateColumn() + @CreateDateColumn({ type: 'timestamptz' }) createdAt?: Date; - @UpdateDateColumn() + @UpdateDateColumn({ type: 'timestamptz' }) updatedAt?: Date; @VersionColumn() diff --git a/apps/api/src/app/core/entities/audit-base.entity.ts b/apps/api/src/app/core/entities/audit-base.entity.ts index 5b92f9d53..9f393db37 100644 --- a/apps/api/src/app/core/entities/audit-base.entity.ts +++ b/apps/api/src/app/core/entities/audit-base.entity.ts @@ -13,12 +13,12 @@ export abstract class AuditBase { @ApiModelProperty({ type: 'string', format: 'date-time', example: '2018-11-21T06:20:32.232Z' }) // @Exclude() - @CreateDateColumn() + @CreateDateColumn({ type: 'timestamptz' }) createdAt?: Date; @ApiModelProperty({ type: 'string', format: 'date-time', example: '2018-11-21T06:20:32.232Z' }) // @Exclude() - @UpdateDateColumn() + @UpdateDateColumn({ type: 'timestamptz' }) updatedAt?: Date; // @Exclude() diff --git a/apps/api/src/app/notifications/notification/notification.entity.ts b/apps/api/src/app/notifications/notification/notification.entity.ts index b0992252a..08090058c 100644 --- a/apps/api/src/app/notifications/notification/notification.entity.ts +++ b/apps/api/src/app/notifications/notification/notification.entity.ts @@ -66,11 +66,11 @@ export class Notification extends Base { isActive?: boolean; @ApiModelProperty({ type: 'string', format: 'date-time', example: '2018-11-21T06:20:32.232Z' }) - @CreateDateColumn() + @CreateDateColumn({ type: 'timestamptz' }) createdAt?: Date; @ApiModelProperty({ type: 'string', format: 'date-time', example: '2018-11-21T06:20:32.232Z' }) - @UpdateDateColumn() + @UpdateDateColumn({ type: 'timestamptz' }) updatedAt?: Date; @Exclude() diff --git a/apps/api/src/app/notifications/subscription/subscription.entity.ts b/apps/api/src/app/notifications/subscription/subscription.entity.ts index 1a5253899..74d2ba3e9 100644 --- a/apps/api/src/app/notifications/subscription/subscription.entity.ts +++ b/apps/api/src/app/notifications/subscription/subscription.entity.ts @@ -28,11 +28,11 @@ export class Subscription extends Base { topics: string[]; @ApiModelProperty({ type: 'string', format: 'date-time', example: '2018-11-21T06:20:32.232Z' }) - @CreateDateColumn() + @CreateDateColumn({ type: 'timestamptz' }) createdAt?: Date; @ApiModelProperty({ type: 'string', format: 'date-time', example: '2018-11-21T06:20:32.232Z' }) - @UpdateDateColumn() + @UpdateDateColumn({ type: 'timestamptz' }) updatedAt?: Date; @Exclude() diff --git a/libs/ngx-utils/package.json b/libs/ngx-utils/package.json index aa6a0b4d2..3c424f973 100644 --- a/libs/ngx-utils/package.json +++ b/libs/ngx-utils/package.json @@ -1,6 +1,6 @@ { "name": "@ngx-starter-kit/ngx-utils", - "version": "0.0.2", + "version": "0.0.3", "peerDependencies": { "@angular/common": ">=6.0.0 <8.0.0", "@angular/core": ">=6.0.0 <8.0.0", diff --git a/libs/ngx-utils/src/lib/pipes/date-fns/format-time-in-words.pipe.ts b/libs/ngx-utils/src/lib/pipes/date-fns/format-time-in-words.pipe.ts index 42da6f558..de1e56cb9 100644 --- a/libs/ngx-utils/src/lib/pipes/date-fns/format-time-in-words.pipe.ts +++ b/libs/ngx-utils/src/lib/pipes/date-fns/format-time-in-words.pipe.ts @@ -74,10 +74,6 @@ export class FormatTimeInWordsPipe implements PipeTransform, OnDestroy { private stringToDate(date: string | number | Date): number | Date { const isString = s => typeof(s) === 'string' || s instanceof String; - console.log(date); - console.log(new Date(date as string)); - console.log(new Date(Date.parse(date as string))); - return isString(date) ? parseISO(date) : date; } }