-
-
Notifications
You must be signed in to change notification settings - Fork 118
Description
Hey @jamesgpearce, thank you for Tinybase! Really been enjoying it. Is an object, array, or JSON type planned for a Cell? It wouldn't need to be deep object/array support, but Postgres, for example, allows you to store an array or JSONB in a column, so this feature would provide for easy mapping to/from a DB.
Or is there a current workaround like transforming an object/array into scalar properties on the store?
(Also, I noticed for #56 that the Prisma schema has array types, so I figured that this feature might be part of it.)
Is your feature request related to a problem? Please describe.
I'm storing array types in the database, so it'd be great to save it as that in the store.
Describe the solution you'd like
Store an object, array, and/or JSON (actually a string but with stringify/parse helpers would work) in a cell.
Describe alternatives you've considered
Transforming data when setting up the store, stringifying the JSON, converting frontend formats to 1NF, etc.
--
Edit: If comparison performance is the main issue (from Discord), a few thoughts:
- Hash compare: Calculate a new hash on Cell save and use that for equality checks
- Single key checks for objects: User provides 1 key that should be checked for whether the object is new (or array index)
- Custom comparison function: Provide the old & new objects and user can be as performant or unperformant as they wish.
- Mark object dirty in Cell update methods
- Mark object dirty via
Proxywatch (tho this would have some mild performance implications) - For memory concerns, explicit garbage collection via
using,DisposableStack,AsyncDisposableStack, etc. is now available (MDN) - If you're open to third party libs Alien Signals is quite performant and has a build-your-own-signals-lib helper (the upcoming Vue 3.6+ will be using it)