Hi in my app I have total number of rooms and numb...
# prisma-whats-new
b
Hi in my app I have total number of rooms and number of rooms booked and these two are in two different tables. So based on the number of rooms booked I need to change the total number of rooms. so, how can I write query to achieve this ?
m
Hey, so because you probably want to display available rooms on client side, you can just fetch both numbers and substract them. However, there’s another apporach. You could change your model, so that
Room
type points to
Booking
type and then just filter out the ones which have no connection. This way, you can also be sure that no Room which doesn’t exists under one table would appear in the other one, which could be in case of predictibility and testing a nice feature. 🙂
c
Whenever you are mutating rooms booked, mutate total number of rooms
m
Ah, you could use
subscriptions
for that, is that what you meant ?