-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(RL-133): adds categorizable model
- Loading branch information
1 parent
17cf8bf
commit 9d14ca1
Showing
8 changed files
with
80 additions
and
2 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
24 changes: 24 additions & 0 deletions
24
src/server/src/api/v1/schema/resources/channel/Categorizable.model.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 { Column, DataType } from 'sequelize-typescript'; | ||
|
||
import { CategorizableAttributes, CategorizableCreationAttributes } from './Categorizable.types'; | ||
import { BaseModel } from '../../base'; | ||
|
||
export class Categorizable< | ||
A extends CategorizableAttributes = CategorizableAttributes, | ||
B extends CategorizableCreationAttributes = CategorizableCreationAttributes> | ||
extends BaseModel<A, B> | ||
implements CategorizableAttributes { | ||
|
||
@Column({ | ||
allowNull: false, | ||
type: DataType.INTEGER, | ||
}) | ||
declare parentId: number; | ||
|
||
@Column({ | ||
allowNull: false, | ||
type: DataType.STRING, | ||
}) | ||
declare category: string; | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/server/src/api/v1/schema/resources/channel/Categorizable.types.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,15 @@ | ||
import { DatedAttributes } from '../../types'; | ||
|
||
export type CategorizableAttributes = DatedAttributes & { | ||
parentId: number; | ||
category: string; | ||
}; | ||
|
||
export type CategorizableCreationAttributes = Partial<DatedAttributes> & { | ||
parentId: number; | ||
category: string; | ||
}; | ||
|
||
export const PUBLIC_CATEGORIZABLE_ATTRIBUTES = ['parentId', 'category'] as const; | ||
|
||
export type PublicCategorizableAttributes = Pick<CategorizableAttributes, typeof PUBLIC_CATEGORIZABLE_ATTRIBUTES[number]>; |
16 changes: 16 additions & 0 deletions
16
src/server/src/api/v1/schema/resources/summary/SummaryCategory.model.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,16 @@ | ||
import { Table } from 'sequelize-typescript'; | ||
|
||
import { | ||
SummaryCategoryAttributes, | ||
SummaryCategoryCreationAttributes, | ||
} from './SummaryCategory.types'; | ||
import { Categorizable } from '../channel/Categorizable.model'; | ||
|
||
@Table({ | ||
modelName: 'summary_category', | ||
paranoid: true, | ||
timestamps: true, | ||
}) | ||
export class SummaryCategory<A extends SummaryCategoryAttributes = SummaryCategoryAttributes, B extends SummaryCategoryCreationAttributes = SummaryCategoryCreationAttributes> extends Categorizable<A, B> implements SummaryCategoryAttributes { | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/server/src/api/v1/schema/resources/summary/SummaryCategory.types.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,13 @@ | ||
import { | ||
CategorizableAttributes, | ||
CategorizableCreationAttributes, | ||
PUBLIC_CATEGORIZABLE_ATTRIBUTES, | ||
PublicCategorizableAttributes, | ||
} from '../channel/Categorizable.types'; | ||
|
||
export type SummaryCategoryAttributes = CategorizableAttributes; | ||
export type SummaryCategoryCreationAttributes = CategorizableCreationAttributes; | ||
|
||
export const PUBLIC_SUMMARY_CATEGORIZABLE_ATTRIBUTES = PUBLIC_CATEGORIZABLE_ATTRIBUTES; | ||
|
||
export type PublicSummaryCategoryAttributes = PublicCategorizableAttributes; |
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