rooms creation ok in db

This commit is contained in:
hugogogo
2023-01-06 17:13:59 +01:00
parent 23105600a5
commit 8be84e8442
3 changed files with 11 additions and 11 deletions

View File

@@ -38,7 +38,7 @@ export class ChatService {
newChatroom.name = joinRoomDto.room_name;
newChatroom.type = joinRoomDto.room_type;
newChatroom.owner = user;
const savedChatroom = this.chatroomRepository.save(newChatroom);
const savedChatroom = await this.chatroomRepository.save(newChatroom);
console.log(savedChatroom);
return "good room";

View File

@@ -1,14 +1,16 @@
import { IsBoolean, IsEmpty, IsIn, IsInt, IsNotEmpty, IsNumber, IsString, IsOptional } from "class-validator";
import { IsBoolean, IsEmpty, IsInt, IsNotEmpty, IsNumber, IsString, IsOptional } from "class-validator";
import { IsNull } from "typeorm";
export class joinRoomDto {
@IsString()
@IsNotEmpty()
room_name : string
@IsString()
@IsNotEmpty()
@IsIn(['public', 'private', 'direct'])
room_type : string
room_type : 'public' | 'private' | 'direct';
@IsString()
@IsOptional()
room_password : string

View File

@@ -9,18 +9,16 @@ import { User } from 'src/users/entities/user.entity';
@Entity('chatroom')
export class Chatroom {
@PrimaryGeneratedColumn()
id: number;
id: number;
@Column()
name: string;
name: string;
@Column()
type: 'public' | 'private' | 'direct';
@Column({ nullable: true })
protection: boolean;
type: 'public' | 'private' | 'direct';
@ManyToOne(type => User, user => user.ownedRoom)
owner: User;
owner: User;
}