#Bug

32 messages · Page 1 of 1 (latest)

halcyon bear
#

I am sending request and always is good. This is request and this is prisma studio. You see that in request says that i already have room. But in Prisma you see i don't have any rooms.

young thorn
#

I would assume that however you're connecting to your database, it isn't the database you think it is

young thorn
#

You send a request that tries to insert data into the database and get an error that the data already exists, right?

halcyon bear
young thorn
#

What do you mean by "room"?

#

Can you show your code? The screenshots don't help

halcyon bear
#

not private chat, so it means group of people

young thorn
halcyon bear
#
const findRoom = this.prismaService.room.findUnique({
                where: {
                    name: createRoom.name
                }
            })
            if(findRoom){
                throw new HttpException('This room was already used', HttpStatus.INTERNAL_SERVER_ERROR);
            }```
young thorn
#

You need to await the cash to prisma

halcyon bear
#

bro do you understand my bug?

young thorn
#

Otherwise findRoom is a Promise which is always truthy

halcyon bear
#

it is not error

young thorn
halcyon bear
#

i am creating room that it names

young thorn
#

You have an if on an always truthy value, so the error will always throw

halcyon bear
#

i don't have anything

young thorn
#

If you await the call to the database, you'll actually have a value or a null in the findRoom and your if check will then be valid

halcyon bear
young thorn
#

Where is the creation code? All you've shown is a find that you don't wait for

#

Please don't call me "bro"

#

And please understand what I've already said trying to help you

halcyon bear
young thorn
#

You should be awaiting this call too

halcyon bear
#

thank you man

fickle lionBOT
#

This post has been marked as resolved. :white_check_mark:
Please read through the conversation and resolution if you are having the same issue, and then re-open the post if you are still having trouble, providing as much extra information as possible.

halcyon bear
young thorn
#

What? Please create a new post with the information one would need to understand what's happening