我正在使用typeorm并使用ViewEntities。我正在按照文档创建视图实体。 https://typeorm.io/#/view-entities。
我运行以下命令来生成迁移文件。 npm run typeorm -- migration:generate -n "Initial"
这是它产生的输出。如您所见,它已损坏并且格式不正确。
import {ViewEntity, ViewColumn} from "typeorm";
@ViewEntity({
expression: `
SELECT "post"."id" AS "id", "post"."name" AS "name", "category"."name" AS "categoryName"
FROM "post" "post"
LEFT JOIN "category" "category" ON "post"."categoryId" = "category"."id"
`
})
export class PostCategory {
@ViewColumn()
id: number;
@ViewColumn()
name: string;
@ViewColumn()
categoryName: string;
}
我如何防止这种情况发生?