-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tag): superTag, defaultTag 가져오는 View Entity 추가
superTag, defaultTag 가져오는 View Entity 추가
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { DataSource, ViewColumn, ViewEntity } from 'typeorm'; | ||
|
||
@ViewEntity('v_tags_super_default', { | ||
expression: ` | ||
SELECT sp1.content, ( | ||
SELECT COUNT(sp1.id) | ||
FROM sub_tag sb1 | ||
WHERE sb1.superTagId = sp1.id | ||
AND sb1.isDeleted IS FALSE AND sb1.isPublic IS TRUE) AS count | ||
FROM super_tag sp1 | ||
WHERE sp1.isDeleted IS FALSE | ||
AND sp1.content != 'default' | ||
UNION | ||
SELECT sb2.content, | ||
0 AS count | ||
FROM sub_tag sb2 | ||
INNER JOIN super_tag sp2 | ||
ON sb2.superTagId = sp2.id | ||
WHERE sp2.content = 'default' | ||
AND sb2.isDeleted IS FALSE | ||
AND sb2.isPublic IS TRUE`, | ||
}) | ||
export class VTagsSuperDefault { | ||
@ViewColumn() | ||
content: string; | ||
|
||
@ViewColumn() | ||
count: number; | ||
} | ||
|
||
export default VTagsSuperDefault; |