import {
	Entity,
	Column,
	ManyToOne,
	ManyToMany,
	JoinTable,
	PrimaryGeneratedColumn
} from "typeorm";
import { User } from 'src/users/entities/user.entity';

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

	@Column()
	name: string;

  @Column()
  type: string;

//  @ManyToOne(type => User, user => user.ownedRooms)
//  owner: User;
//
//	@ManyToMany(type => User)
//	@JoinTable()
//	users: User[];

  @Column()
  owner: string; // username

  @Column("simple-array")
	users: string[]; // usernames

  @Column("json")
	messages: { name: string, message: string }[];
}

