Storing received data in one field

Hey,

I’m storing data in “Content” data type, but also I need to store it in “content” column of another data type in my db, so each field of “content” will own all of Content’s data.

In code it would be:
Content = {
link: ‘www’
duration: ‘36’,
thumbnail: ‘thumb.jpg’,
etc
}
content = [Content1, Content2, etc]

Any idea guys? :sos:

Hi there, @orpt.dev… the way to do that in Bubble is to set the content column’s field type to Content (i.e., the field type is set up to reference another data type). Then, when a thing is created in the Content data type, you save that thing to the content field of the related thing in the Playlist data type. At that point, you have access to all of the fields in the Content data type via a thing in the Playlist data type. So, you could end up with a query that looks something like This Playlist's content's thumbnail.

Does that make sense? Hope it helps.

Best…
Mike

Hi Mike, thanks for the fast answer :smiley:

So I did exactly what you said and it works, but all I get in Playlist’s content is the created Content’s ID.
Is there a way to Content’s data as it is like the object I gave as example?
In the future I’ll need to fetch this data so I’m trying to reduce the API calls as much as I can.

Yup, that’s how Bubble does it. The only thing I can think of is to have fields in the Playlist data type for link, duration, thumbnail, etc. and save the content directly to those fields, but maybe someone else will come along and suggest something different/better.

Best…
Mike

Oh, wait… there is no value in putting those fields in the Playlist data type if you are storing the items in the Content data type. What API calls are you going to be making if the data is stored in the Bubble db?

Thanks again Mike :slight_smile:

I made it through ‘Request data from API’ in the backend workflows and it works great.
I’m just fetching a custom object with exactly what I need from the DB.

Thanks

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.