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.name = joinRoomDto.room_name;
newChatroom.type = joinRoomDto.room_type; newChatroom.type = joinRoomDto.room_type;
newChatroom.owner = user; newChatroom.owner = user;
const savedChatroom = this.chatroomRepository.save(newChatroom); const savedChatroom = await this.chatroomRepository.save(newChatroom);
console.log(savedChatroom); console.log(savedChatroom);
return "good room"; 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"; import { IsNull } from "typeorm";
export class joinRoomDto { export class joinRoomDto {
@IsString() @IsString()
@IsNotEmpty() @IsNotEmpty()
room_name : string room_name : string
@IsString() @IsString()
@IsNotEmpty() @IsNotEmpty()
@IsIn(['public', 'private', 'direct']) room_type : 'public' | 'private' | 'direct';
room_type : string
@IsString() @IsString()
@IsOptional() @IsOptional()
room_password : string room_password : string

View File

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