I’m trying to save a list of JSON objects (exercises), that are nested in another list of JSON objects (workouts), into the database. But I’m stuck!
Here is the JSON response I’ve got back. I’m trying to get this structure saved to the database. So a workout program, can contain a number of different individual workouts, and for each workout there are a number of individual exercises.
My database is structured:
Workout program >> contains list of Workouts
Workout >> contains List of exercises
I’ve tried to run an API on a list of ‘workouts’ (add_workout_from_list). which creates a new workout in the database and then runs another API on a list of exercises (add_exercises_to_wo) but I can’t seem to pass through the list of ‘exercises’ for each ‘workout’
Thanks Doug. I can save the workout list data and the exercise list data separately, but I can’t get them saved on the DB in the same way they are nested in the JSON.
For example, I can run a BE WF on Workout list fine, but then when I go to run a second BE WF on the Exercise JSON nested within one of the Workouts on the list, I can only get it to pickup the first exercise.
Hey @akalati . I was using Open AI API to create my JSON so I changed the prompt so that the nested JSON output contained an identifier for the object it was nested in.
In this case the ‘exercise’ object contains the workout number of the ‘workout’ it is nested in.
I then ran seperate recursive backend workflows on list of workouts and list of exercises (with a 1 second delay for the latter). On the recursive workflow for list of exercise, after creating an exercise, I then made changes to a thing: 'do search for workouts where workout number = workout number in the exercise JSON. Therefore, linking the exercise to the workout it was nested in.
Yes, that’s exactly what I needed as well and would have solved so much headache. Do you suppose that can have OpenAI convince Amazon to do the same with their API responses ? I actually got it working, by scratching my left ear, with my right hand! I kept things on a flat level with the parent fields as-is, and each of the line’s fields as a concatenated blob that I then decompose into a native list. All this headache would be gone if bubble gave us a way to pass more than just primitives to BWFs!
I’m trying to understand that as well… Any chance you can share your database type ? Have you got all Workout and Exercice in the same Data table ? Or it remains in different tables ?
One solution is to ask the AI to return the JSON as text instead of JSON structure. Then you can convert it into a Bubble structure, so it is easier to process and save it to DB.