import { Entity, Column, ManyToOne, ManyToMany, JoinTable, PrimaryGeneratedColumn } from "typeorm";
import { IsBoolean, IsEmpty, IsInt, IsIn, IsNotEmpty, IsNumber, IsArray, IsString, IsOptional, IsEnum } from "class-validator";
import { Exclude, Expose } from 'class-transformer';
import { User } from 'src/users/entities/user.entity';
import { messagesDto } from 'src/chat/dto/messages.dto';

@Entity('chatroom')
export class Chatroom
{
	@PrimaryGeneratedColumn()
	id: number;

	@Column()
	@IsString()
	@IsNotEmpty()
	name: string;

	@Column()
	@IsString()
	@IsNotEmpty()
	@IsIn(["public", "protected", "private", "direct", "user"])
	type: string;

  @Column()
  owner: string; // username

  @Column("simple-array")
	@IsArray()
	@IsString({ each: true })
	@IsOptional()
	users?: string[]; // usernames

  @Column("json")
	messages: messagesDto[];
}

