arrays - 如何在 TypeOrm 实体中添加枚举数组?
问题描述
我正在进行大量研究和实验以在我的实体中使用枚举数组。
import { Program } from '../../program/entities/program.entity'
import {
Column,
Entity,
JoinTable,
ManyToMany,
ManyToOne,
PrimaryGeneratedColumn,
} from 'typeorm'
import { Exercise } from '../../exercise/entities/exercise.entity'
import { WeekDays } from '../types/week-days.enum'
@Entity()
export class Workout {
// [...]
@Column({
type: 'enum',
enum: WeekDays,
default: [],
array: true,
})
scheduledDays?: WeekDays[]
constructor(partial: Partial<Workout> | {} = {}) {
Object.assign(this, partial)
}
}
不幸的是,它给了我这个错误。
QueryFailedError: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'array ('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sund' at line 1
我该如何解决这个问题?我无法理解我的装饰器选项有什么问题。
解决方案
推荐阅读
- r - 连续平均值和百分位数的计算
- javascript - 使用本地存储进行数据捕获的注册表单
- laravel - Laravel - 排队多个数据库
- python - 为什么 Flask SQL Alchemy 允许保存 None 的主键?
- r - 如何获取空值以在 Shiny 中使用 selectInput
- python - 难以理解 python 中的某些代码
- css - 转换和过渡在 iOS Safari 中不起作用
- class - Dafny - 从 Main 调用类方法后违反断言
- arrays - 当修剪和清除不起作用时删除数字中的空格
- java - 如何为接受文件作为参数的主要方法编写junit测试