Yeah, @ihsanzainal84, here’s the thing:
One HUGE limitation of Bubble is that we have no real access to objects (by which I mean JavaScript objects) created in the page. The only objects we have access to are Things. And a Thing can only be made to exist via interaction with the database.
So, even though a plugin could create an object – for example, something that sort of looks like a Thing (in that it might have all the fields of a Thing that you’ve defined in your app) – we have no way to publish that back up to Bubble as an object. A hacky workaround would be to build a plugin with a terrible interface that allows you to define the types and outputs of certain scalar or list fields that correspond to the fields of a Thing, but the interface there is terrible (and cannot support an arbitrary number of such fields).
(Additionally, plugins cannot directly create new Things, nor make changes to existing Things. This can only be done by the Bubble programmer using the Create New and Make Changes to a Thing Actions.)
Now: Of course you can define an object as JSON (that’s just a string) and you can save such a string in local/session/indexdb storage using Floppy by specifying the key type as text. And then, when read back you could process it using the techniques that you (and @providers ) already seem to understand.
So, I don’t see much advantage to trying to do things that way. Let’s say you ideally wanted to store an object in storage that has a string field, a number field and an array of dates. (This is just an arbitrary example.) Let’s say this object represents a calendar or something.
Well, rather than making this hard, just store these items independently as different keys of the appropriate types: a Floppy for the string field, a Floppy for the number field, and a Floppy for the list of date type. If you want to make it “feel” like working with objects you could give the key names names like calendar.name, calendar.number, and calendar.dates.
If you’re using IndexedDB as your storage, you can make this even more object-like, because IndexedDB allows you to name a database and then name a unique data store.
So what you might do is have those 3 Floppy’s set up like:
- Three Floppys set to IndexedDB using database name “myapp” and datastore name “calendar”, but each writes to a different key in calendar by specifying one to use key “name” (a text), key “number” a number, and “dates” a list of dates.
- Now, that “calendar” datastore is basically like your own private localStorage, but conceptually its just for holding the fields that correspond to your “calendar” object.
- Now as you manipulate those 3 keys, you are basically just reading and writing the individual fields of calendar.
If you don’t need to do any of the fancy list manipulation / math / iteration stuff in Floppy, you can instead use the Floppy Storage (in later versions, renamed Floppy Reader – there’s just no good name for that thing) element to access all of those keys from a single Floppy Storage element.
Once I do some video show and tell about IndexedDB this will become more clear if I haven’t made it clear already.