2019-05-18 06:36:33 -05:00
|
|
|
import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne } from 'typeorm';
|
2022-02-26 20:07:39 -06:00
|
|
|
import { User } from './user.js';
|
|
|
|
import { id } from '../id.js';
|
2019-05-18 06:36:33 -05:00
|
|
|
|
|
|
|
@Entity()
|
|
|
|
export class UserGroup {
|
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('timestamp with time zone', {
|
2021-12-09 08:58:30 -06:00
|
|
|
comment: 'The created date of the UserGroup.',
|
2019-05-18 06:36:33 -05:00
|
|
|
})
|
|
|
|
public createdAt: Date;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 256,
|
|
|
|
})
|
|
|
|
public name: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
2021-12-09 08:58:30 -06:00
|
|
|
comment: 'The ID of owner.',
|
2019-05-18 06:36:33 -05:00
|
|
|
})
|
|
|
|
public userId: User['id'];
|
|
|
|
|
|
|
|
@ManyToOne(type => User, {
|
2021-12-09 08:58:30 -06:00
|
|
|
onDelete: 'CASCADE',
|
2019-05-18 06:36:33 -05:00
|
|
|
})
|
|
|
|
@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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|