0
votes

I have been trying to make an array of numbers in type orm in my User entity, but type orm keeps showing up this problem

The code

@Entity()
class User {
    @PrimaryGeneratedColumn()
    id: number;

    @Column()
    username: string;

    @Column()
    password: string;

    @Column()
    points: number;

    @Column()
    time: number[];
};

And the error in terminal is it :

(node:25398) UnhandledPromiseRejectionWarning: DataTypeNotSupportedError: Data type "Array" in "User.time" is not supported by "postgres" database. at new DataTypeNotSupportedError (/home/vinicius/www/Projects/Quizzer/backend/node_modules/typeorm/error/DataTypeNotSupportedError.js:7:28) at /home/vinicius/www/Projects/Quizzer/backend/node_modules/typeorm/metadata-builder/EntityMetadataValidator.js:74:27 at Array.forEach () at EntityMetadataValidator.validate (/home/vinicius/www/Projects/Quizzer/backend/node_modules/typeorm/metadata-builder/EntityMetadataValidator.js:71:36) at /home/vinicius/www/Projects/Quizzer/backend/node_modules/typeorm/metadata-builder/EntityMetadataValidator.js:42:74 at Array.forEach () at EntityMetadataValidator.validateMany (/home/vinicius/www/Projects/Quizzer/backend/node_modules/typeorm/metadata-builder/EntityMetadataValidator.js:42:25) at Connection.buildMetadatas (/home/vinicius/www/Projects/Quizzer/backend/node_modules/typeorm/connection/Connection.js:498:33) at Connection. (/home/vinicius/www/Projects/Quizzer/backend/node_modules/typeorm/connection/Connection.js:128:30) at step (/home/vinicius/www/Projects/Quizzer/backend/node_modules/tslib/tslib.js:141:27) (node:25398) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:25398) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

1

1 Answers

0
votes

From this:

@Entity()
class User {
    @PrimaryGeneratedColumn()
    id: number;

    @Column()
    username: string;

    @Column()
    password: string;

    @Column()
    points: number;

    @Column("int", { array: true })
    time: number[];
};

Hope it helps :)