views:

33

answers:

1

I have a simple client-side Sqlite database (via. Google Gears) I want to use for persistence of the contents of a javascript object's properties (not methods). I don't really care about normalization since it has lots of potentially disparate fields (primitive types, arrays, objects) that would thwart normalization anyway.

What would be the best way to go about doing this? Or in the worst case, an alternative that at least achieves persistence?

+1  A: 

If you don't need type information for your objects (and they contain no methods, only attributes) why not store your data as JSON?

Sean Vieira
And do what with that JSON data that persists it? Stick it all in one big string in a single-item database table?
Hamster
If you're only using it for persistence and you're not versioning the object in question, then yes, just a single column table will do.
Sean Vieira
I guess that works.
Hamster
@Hamster -- Glad I could help! The reason I suggest this approach is for speed. Breaking down the object (which will have many disparate fields) *just* for persistence will slow down the speed of serializing / deserializing the object -- and, according the OP, add no needed functionality to what is being built. Simplicity wins over nifty. :-)
Sean Vieira