Skip to content

Commit

Permalink
feat(tag): superTag, defaultTag 가져오는 View Entity 추가
Browse files Browse the repository at this point in the history
superTag, defaultTag 가져오는 View Entity 추가
  • Loading branch information
nyj001012 committed Jul 18, 2023
1 parent 7f7a6c4 commit 0878cad
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions backend/src/entity/entities/VTagsSuperDefault.ts
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;

0 comments on commit 0878cad

Please sign in to comment.