summaryrefslogtreecommitdiff
path: root/packages/backend/src/models/entities/RoleAssignment.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-01-12 21:02:26 +0900
committerGitHub <noreply@github.com>2023-01-12 21:02:26 +0900
commit2470afaa2e200fb2fc748e0f8eef5e2c215369b6 (patch)
treec270452679996127a9d15c4ba5f97b39bb9ba560 /packages/backend/src/models/entities/RoleAssignment.ts
parentUpdate CHANGELOG.md (diff)
downloadsharkey-2470afaa2e200fb2fc748e0f8eef5e2c215369b6.tar.gz
sharkey-2470afaa2e200fb2fc748e0f8eef5e2c215369b6.tar.bz2
sharkey-2470afaa2e200fb2fc748e0f8eef5e2c215369b6.zip
Role (#9437)
* wip * Update CHANGELOG.md * wip * wip * wip * Update create.ts * wip * wip * Update CHANGELOG.md * wip * wip * wip * wip * wip * wip * wip * Update CHANGELOG.md * wip * wip * Update delete.ts * Update delete.ts * wip * wip * wip * Update account-info.vue * wip * wip * Update settings.vue * Update user-info.vue * wip * Update show-file.ts * Update show-user.ts * wip * wip * Update delete.ts * wip * wip * Update overview.moderators.vue * Create 1673500412259-Role.js * wip * wip * Update roles.vue * 色 * Update roles.vue * integrate silence * wip * wip
Diffstat (limited to 'packages/backend/src/models/entities/RoleAssignment.ts')
-rw-r--r--packages/backend/src/models/entities/RoleAssignment.ts42
1 files changed, 42 insertions, 0 deletions
diff --git a/packages/backend/src/models/entities/RoleAssignment.ts b/packages/backend/src/models/entities/RoleAssignment.ts
new file mode 100644
index 0000000000..e86f2a8999
--- /dev/null
+++ b/packages/backend/src/models/entities/RoleAssignment.ts
@@ -0,0 +1,42 @@
+import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
+import { id } from '../id.js';
+import { Role } from './Role.js';
+import { User } from './User.js';
+
+@Entity()
+@Index(['userId', 'roleId'], { unique: true })
+export class RoleAssignment {
+ @PrimaryColumn(id())
+ public id: string;
+
+ @Column('timestamp with time zone', {
+ comment: 'The created date of the RoleAssignment.',
+ })
+ public createdAt: Date;
+
+ @Index()
+ @Column({
+ ...id(),
+ comment: 'The user ID.',
+ })
+ public userId: User['id'];
+
+ @ManyToOne(type => User, {
+ onDelete: 'CASCADE',
+ })
+ @JoinColumn()
+ public user: User | null;
+
+ @Index()
+ @Column({
+ ...id(),
+ comment: 'The role ID.',
+ })
+ public roleId: Role['id'];
+
+ @ManyToOne(type => Role, {
+ onDelete: 'CASCADE',
+ })
+ @JoinColumn()
+ public role: Role | null;
+}