为ViewEntity生成迁移会返回错误的输出

时间:2020-07-09 09:28:25

标签: node.js typescript typeorm

我正在使用typeorm并使用ViewEntities。我正在按照文档创建视图实体。 https://typeorm.io/#/view-entities

我运行以下命令来生成迁移文件。 npm run typeorm -- migration:generate -n "Initial"这是它产生的输出。如您所见,它已损坏并且格式不正确。

enter image description here

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;

}

我如何防止这种情况发生?

0 个答案:

没有答案