Hello all friends!
I’m pulling some data from an API and saving it to the bubble database. So far everything is configured and everything is working. Now I have a doubt on how to proceed. Some values that are saved in the database are numbers, which correspond to values as text. For example I can get and save in the pie type field the number 2 (this number comes from the API). I have a table where I know number 2 is a New York Cheesecake. How can I get the number 2 associated with NY cheesecake?
Thanks friends!
I assume you have a datatype for the food/item (New York Cheesecake is this item type). If you don’t, then create one and add your foods/items using a UI or the data tab in the editor. On that type, have a field APINumber
or something like that which is the number you get from your API. Pie Type = Do a search for Items (ID = API’s number):first item
Thank you very much for your answer! It may actually be a road. Now I have a doubt. What I had in mind was this path:
- I call the data through the API and with the help of the backend workflows I save them as they are in the database;
- I would like to immediately replace all those fields which appear as “numbers” and therefore which are not already identified with a “text” (as in the example above, I would like to replace the number 2 in the database, with the writing NY cheesecake);
- Save the value NY Cheesecake to the database by replacing the number 2.
Do you think it’s feasible?
I mean, you can add a conditional where if number = 2 then set text to NY Cheesecake but it’s not scaleable.
Create a data type ‘Pie Type’ with field ‘apiID’ (type number) and ‘name’ (type text). Add each item to the database so for your cheesecake click create new entry and set the apiID to 2 and name to NY Cheesecake or whatever.
When you want to work out the pie type from the API number, do a search for Pie Types where number = API’s number:first item.
This is the method that will help you most in the long run, it just requires you adding your pie name/number pairs to the Bubble database.
1 Like