Pull data from another table, via ref. id in API

Options
For context, I am building a journal app.

I have a database which contains user submitted entries called 'Entries', each entry is made up of answers: 'Input1' 'Input2' 'Input3', to a number of prompts:
[Screenshot 2022-03-13 at 13.47.35.png]
The prompts are pulled from a separate database called 'Guided Exercises' and are associated with each entry by a 'guided_exercises_id'.
[Screenshot 2022-03-13 at 13.47.35.png]
What I want to do is display a users 'Entries' in my front end, and also pull the prompts, along with the answers, using the Guided Exercise ID. So it would look something like this in the front end:

Prompt 1: How do you feel?
Input1: I feel energetic

Prompt2: What have you done today?
Input2: Gone for a run

Here is that my API to get (and decrypt) the Entries currently:
[screencapture-xnld-vjkh-drol-e2-xano-io-admin-workspace-1-api-1-query-61-2022-03-13-13_53_47.png][Screenshot 2022-03-13 at 13.54.20.png]
How can I make this API also make the guided exercise prompts, pulled via id, part of this result?

Comments

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options
    I think you're looking for each result to contain prompt_1, prompt_2 etc that would match to input_1, input_2? You can, inside your for loop, run an update, setting the "item.prompt_1" to whatever the right text is. That "right text" can come from a separate database lookup or whatever logic you see fit. The important idea is that "update" can create new keys, in addition to changing (in this case decrypting) the old ones. 
  • Steve Wright-2225084
    Options
     Thanks Ray, any chance you could screen grab what that might look like? 

    I'm stuck trying to setup the 'run an update' within the loop that successfully pulls the 'right text' from the 'separate database'.