NestJS 我如何查询数据库中的视图

NestJS How I make query to views in an database

我有一个小问题,我的问题是如何查询数据库中的视图?。我基于这个例子 enter link description here

我的代码是一个实体:

import { ViewEntity, Connection } from 'typeorm';

@ViewEntity({
    expression: (connection: Connection) => connection.createQueryBuilder()
    .select('id')
    .from(V1, 'v1'), }) 

}
export class V1 {

}

我在控制台中的错误记录:

您可以使用视图实体,如更新文档中所述: https://typeorm.io/#/view-entities

例如:

@ViewEntity({ 
    expression: (connection: Connection) => connection.createQueryBuilder()
        .select("post.id", "id")
        .addSelect("post.name", "name")
        .addSelect("category.name", "categoryName")
        .from(Post, "post")
        .leftJoin(Category, "category", "category.id = post.categoryId")
})