#Bug
32 messages · Page 1 of 1 (latest)
I would assume that however you're connecting to your database, it isn't the database you think it is
what?
You send a request that tries to insert data into the database and get an error that the data already exists, right?
No I am trying to find room name in db like name sended in request and if it is true i am sending error.
not private chat, so it means group of people
I don't know what that has to do with anything
const findRoom = this.prismaService.room.findUnique({
where: {
name: createRoom.name
}
})
if(findRoom){
throw new HttpException('This room was already used', HttpStatus.INTERNAL_SERVER_ERROR);
}```
You need to await the cash to prisma
bro do you understand my bug?
Otherwise findRoom is a Promise which is always truthy
it is not error
"Bro" do you understand your code?
i am creating room that it names
You have an if on an always truthy value, so the error will always throw
i am creating room it names for example Hello and then i am creating room that names Hello also and then it says this room already used but i don't have this room model in database
i don't have anything
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
bro. When i just creating a room without error it is not adding to my database
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
const room = this.prismaService.room.create({
data: {
name: createRoom.name,
userId,
ownerId,
type: 'room'
}
})```
You should be awaiting this call too
f*ck i am doing await always but now i forgot
thank you man
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.
Bro i am deleting any data in prisma studio but it isn't deleting
What? Please create a new post with the information one would need to understand what's happening