2023-01-13 05:40:33 +01:00
|
|
|
import {
|
|
|
|
Entity,
|
|
|
|
Index,
|
|
|
|
JoinColumn,
|
|
|
|
Column,
|
|
|
|
PrimaryColumn,
|
|
|
|
ManyToOne,
|
|
|
|
} from "typeorm";
|
|
|
|
import { User } from "./user.js";
|
|
|
|
import { id } from "../id.js";
|
2019-05-18 13:36:33 +02:00
|
|
|
|
|
|
|
@Entity()
|
|
|
|
export class UserGroup {
|
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Index()
|
2023-05-29 18:31:02 +02:00
|
|
|
@Column("timestamp with time zone", {
|
|
|
|
comment: "The created date of the UserGroup.",
|
2019-05-18 13:36:33 +02:00
|
|
|
})
|
|
|
|
public createdAt: Date;
|
|
|
|
|
2023-05-29 18:31:02 +02:00
|
|
|
@Column("varchar", {
|
2019-05-18 13:36:33 +02:00
|
|
|
length: 256,
|
|
|
|
})
|
|
|
|
public name: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
2023-05-29 18:31:02 +02:00
|
|
|
comment: "The ID of owner.",
|
2019-05-18 13:36:33 +02:00
|
|
|
})
|
2023-01-13 05:40:33 +01:00
|
|
|
public userId: User["id"];
|
2019-05-18 13:36:33 +02:00
|
|
|
|
2023-05-29 18:31:02 +02:00
|
|
|
@ManyToOne((type) => User, {
|
|
|
|
onDelete: "CASCADE",
|
2019-05-18 13:36:33 +02:00
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public user: User | null;
|
|
|
|
|
2023-05-29 18:31:02 +02:00
|
|
|
@Column("boolean", {
|
2019-05-18 13:36:33 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|