summaryrefslogtreecommitdiff
path: root/packages/backend/src/models/entities/UserGroup.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/backend/src/models/entities/UserGroup.ts')
-rw-r--r--packages/backend/src/models/entities/UserGroup.ts46
1 files changed, 46 insertions, 0 deletions
diff --git a/packages/backend/src/models/entities/UserGroup.ts b/packages/backend/src/models/entities/UserGroup.ts
new file mode 100644
index 0000000000..328a1883cb
--- /dev/null
+++ b/packages/backend/src/models/entities/UserGroup.ts
@@ -0,0 +1,46 @@
+import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne } from 'typeorm';
+import { id } from '../id.js';
+import { User } from './User.js';
+
+@Entity()
+export class UserGroup {
+ @PrimaryColumn(id())
+ public id: string;
+
+ @Index()
+ @Column('timestamp with time zone', {
+ comment: 'The created date of the UserGroup.',
+ })
+ public createdAt: Date;
+
+ @Column('varchar', {
+ length: 256,
+ })
+ public name: string;
+
+ @Index()
+ @Column({
+ ...id(),
+ comment: 'The ID of owner.',
+ })
+ public userId: User['id'];
+
+ @ManyToOne(type => User, {
+ onDelete: 'CASCADE',
+ })
+ @JoinColumn()
+ public user: User | null;
+
+ @Column('boolean', {
+ default: false,
+ })
+ public isPrivate: boolean;
+
+ constructor(data: Partial<UserGroup>) {
+ if (data == null) return;
+
+ for (const [k, v] of Object.entries(data)) {
+ (this as any)[k] = v;
+ }
+ }
+}