Home > front end >  type of time in typescript
type of time in typescript

Time:01-03

this is error

[7:23:25 PM] Starting compilation in watch mode...

src/users.entity.ts:16:8 - error TS2304: Cannot find name 'time'.

16   time:time;
          ~~~~

src/users.entity.ts:16:8 - error TS4031: Public property 'time' of exported class has or is using private name 'time'.

16   time:time;
          ~~~~

[7:23:35 PM] Found 2 errors. Watching for file changes.

this is code

import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';

@Entity()
export class virtual_user {

 @Column()
  domain_name: string;

  @PrimaryGeneratedColumn()
  email: string;

 @Column()
  password: string;

  @Column()
  time:time;

 @Column()
  department: string;
 @Column({ default:1 })
  status_id:number;
}
  • how can i fix the error and Thanks .

  • how can i fix the error and Thanks .

  • how can i fix the error and Thanks .

  • how can i fix the error and Thanks .

CodePudding user response:

there's no type time on TypeScript. Instead, use the type string or Date, and @Column({ type: 'time' }) or whatever.

Don't confuse typescript types with database datatypes.

CodePudding user response:

    // For a date with the timezone offset
    @Column({ type: 'timestamptz' })
    time: Date;
    // For a date without the timezone offset
    @Column({ type: 'timestamp' })
    time: Date;
  • Related