0

am trying to figure out how to update this table, so when an order is placed, spots decrease by that order, and also free is updated. Then once a person checks out free will increment.

{
id: 1,
title: "Hotel 1",
price: 5,
rating: 4.2,
spots: 20,
free: 10,
coordinate: {
  latitude: 37.78735,
  longitude: -122.4334
},
description: `Description about this place`

}

KaliBoy
  • 121
  • 1
  • 4
  • Hmmm, that doesn't seem an ideal approach. You are not tracking the spots on a spot level? This should be some sort of aggregation query ideally, no? – Abraham Labkovsky Dec 14 '20 at 17:35
  • @AbrahamLabkovsky yes am tracking the spots spot level, like each hotel has several spots. Do you have another approach you would suggest? – KaliBoy Dec 15 '20 at 16:24
  • if you have a `spot` table, and some kind of a `available` or `checked_out` field, you would not need to update anything on the `hotel` table. Assuming your order flow changes the `spot` row status, you can make an aggregate subquery – Abraham Labkovsky Dec 15 '20 at 18:10
  • let us know your part of your schema related to the question... and we'll find a way :) – Muluken Getachew Dec 16 '20 at 08:06

0 Answers0