javascript - postgres 不支持 TypeORM 数组?

标签 javascript node.js postgresql typescript typeorm

我有一个 kid_ages 列,它是 Integer[]。迁移时,出现以下错误:

DataTypeNotSupportedError:“postgres”数据库不支持“home.kid_ages”中的数据类型“Array”。

我尝试在我的专栏中添加以下选项:

type: 'array'

和:

array: true,
default: [],
nullable: false,

@Column({
  array: true,
  default: [],
  nullable: false,
})
kid_ages: string;

最佳答案

文档说,它应该可以工作:

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

这是来自示例 https://github.com/typeorm/typeorm/blob/master/test/functional/database-schema/column-types/postgres/entity/Post.ts

在您的代码中,数组属性不是数组。 您尝试过 kid_ages: string[]; 吗?

关于javascript - postgres 不支持 TypeORM 数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57611633/

相关文章:

javascript - Sequelize.js setter 函数没有按我的预期工作

node.js - `app.get("/", func1, func2);` 与 `app.get("/", func1); app.get("/", func2);` 相同吗?

postgresql - flyway 使用现有数据库

sql - 将具有相似字符串的行分组

javascript - 计算撞击倾斜墙壁后的 Angular 变化

javascript - jQuery - 根据条件禁用和启用 anchor 标记

javascript - 复选框状态需要显示或隐藏一个 div

node.js - Mongoose 栖息在哪里

javascript - 选择和 If 语句

Angular 通用连接的postgresql问题