Nested, very nested database edit

Options
 Hi Xano Team

I am struggling to edit/update a database record based on the below database structure.
[db1.PNG][db2.PNG]
[db3.PNG]I would like to edit/update the qty field in the available_slots list as shown in the above screen.

Can you please assist in advising which filters/structure I should use to edit a specific record?
[edit.PNG]

Comments

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options
    I would: 
    1) run a "get record" query to pull the record from "tour_time_slots" that matches the ID, call the result "record." 
    2) Create a new variable "slots" based on "record.slots". 
    3) Update slots based on what you want - presumably looking for a matching date and updating the quantity, but I don't know what you are looking for for sure.There are a few ways to do this, but I'm assuming for the moment you're just updating "slots" 
    4) Update the "tour_time_slots" table based on the ID, and setting "slots" to "slots"

    The key is that the table stores all the slots as a single field in a single record, so a (relatively) simple approach is to update/replace the whole array.

    All of this takes the existing data structure as a given - you might have more simplification opportunities if the table setup itself is up for grabs. 

    Hope some of the preceding is helpful!