Data Value as Array, String or Object

I am trying to understand and implement database structures that Moltin, an e-commerce API service, provides to my Bubble app. In their documentation, one of the models (product-modifier) allows value that can either be an array, a string or an object. See the screenshot below:

As far as I understand, I must set a data type to create a thing in Bubble. How would I implement a similar database structure in Bubble? Or any workarounds you could think of? I am new to backend/database, so any thought would be really helpful. Thanks! :slight_smile:

You may need a different API call for each type of result, the API connector only captures one example result set.

Alternatively, return as Text and parse it with Bubble’s text functions, kind of hard to do this.

Good luck!

Thanks for your reply. :slight_smile: I actually didn’t mean to use their APIs - I am new to programming so I am mimicking their database structure (just to understand how to well architect databases for e-commerce apps). They have an object whose property value could either be an array of objects, a string, or an object. But in Bubble I should explicitly define a data type – can I define a name-value pair whose value’s data type can be changed?

Interesting idea!

I think the closest you can get is either:

  • A field for each of the different types, another field specifying which field is “in use”.

  • A text field with some kind of predefined formatting, with a second field, or a prefix in the text field, that tells what type the text field represents. Something like a JSON string perhaps. Bubble’s text manipulation doesn’t cover this well, but you can use javascript if all the manipulation can be done on the browser.

I think I will go with the first solution :slight_smile: Sounds simple but doable. Thanks for your support!

1 Like