summaryrefslogtreecommitdiff
path: root/src/models/entities/user-group.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2019-05-18 20:36:33 +0900
committersyuilo <syuilotan@yahoo.co.jp>2019-05-18 20:36:33 +0900
commitc7cc3dcdfd2c0962a39e7186852a17dbd09b6a5b (patch)
treec2e1671787c00daa8963c879dba6fbdab6f02d66 /src/models/entities/user-group.ts
parentFix bug (diff)
downloadsharkey-c7cc3dcdfd2c0962a39e7186852a17dbd09b6a5b.tar.gz
sharkey-c7cc3dcdfd2c0962a39e7186852a17dbd09b6a5b.tar.bz2
sharkey-c7cc3dcdfd2c0962a39e7186852a17dbd09b6a5b.zip
ユーザーグループ
Resolve #3218
Diffstat (limited to 'src/models/entities/user-group.ts')
-rw-r--r--src/models/entities/user-group.ts46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/models/entities/user-group.ts b/src/models/entities/user-group.ts
new file mode 100644
index 0000000000..f4bac03223
--- /dev/null
+++ b/src/models/entities/user-group.ts
@@ -0,0 +1,46 @@
+import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne } from 'typeorm';
+import { User } from './user';
+import { id } from '../id';
+
+@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;
+ }
+ }
+}