-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(postgres): postgres query runner to create materialized view (#4877)
- Loading branch information
1 parent
13f06bf
commit d744966
Showing
5 changed files
with
58 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
test/functional/view-entity/postgres/entity/PostByCategory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {Connection} from "../../../../../src"; | ||
import {ViewColumn} from "../../../../../src/decorator/columns/ViewColumn"; | ||
import {ViewEntity} from "../../../../../src/decorator/entity-view/ViewEntity"; | ||
import {Category} from "./Category"; | ||
import {Post} from "./Post"; | ||
|
||
@ViewEntity({ | ||
materialized: true, | ||
expression: (connection: Connection) => connection.createQueryBuilder() | ||
.select("category.name", "categoryName") | ||
.addSelect("COUNT(post.id)", "postCount") | ||
.from(Post, "post") | ||
.innerJoin(Category, "category", "category.id = post.categoryId") | ||
.groupBy("category.name") | ||
}) | ||
export class PostByCategory { | ||
|
||
@ViewColumn() | ||
categoryName: string; | ||
|
||
@ViewColumn() | ||
postCount: number; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters