views:

463

answers:

5

I'm looking for something like a database for GWT objects (inside the browser). It must work without HTML5 or Gears (or any browser plugins). It doesn't have to be capable of everything a database can do, but the most important features would be

  • automated indexing, on multiple columns
  • some kind of API or language to perform (a limited subset of) queries

It could be a bit similar to Taffy DB, but it must have automated indexing, and it should provide a GWT API. I hope, it would be even smaller in download size than Taffy, if it re-uses code from the GWT library.

(Maybe I should add, that I don't need permanent storage. It's ok, if the data has to be reloaded/regenerated when the user hits reload.)

A: 

Have you looked at SQLite? Here's a handy video tutorial...

http://www.youtube.com/watch?v=DZSZIfhzc3A

Gary Rowe
I see now, that my question probably isn't clear on this point: I said "It must work without HTML5 or Gears." - but what I mean with that, is that it should work on all GWT-supported browsers (maybe except the very old ones), without the user installing anything (not even Flash). I'm talking about a pure JavaScript solution (like Taffy).
Chris Lercher
+1  A: 

You may take a look at itemscript, it has an in memory "database" which you can query using REST-like URL fragments. I haven't tried it but it looks promising. I have to agree with tdavies that if you like Taffy, writing JSNI wrapper around it is quite trivial task.

Some time ago I created simple in-memory database-like system in GWT, where I leveraged existing Comparator interface for sorting, created simple Filter interface, and simple Query used to store any number of Comparators and Filters. Simple generic ModelManager class which stored model objects in one of collection classes and was running my Queries. It worked pretty well even without any support for indexing.

You won't find any existing solutions for your problem, I spent huge amount of time looking for one. Apart of that, why not give HTML5 a try?

skrat
ItemScript is a good idea - a REST API may really be useful. | A homegrown is the most likely solution for me, too. | HTML5: The app must at least run on IE7 (I'm already happy, that I can probably drop IE 6)...
Chris Lercher
A: 

Have you looked at Dojo's Data Store?

I'm not sure how well it fits your specific needs, but it's a pure JavaScript solution. Like much of Dojo, the documentation can be a bit difficult to sort through, but there's an article about using Dojo Grid and the basic MVC pattern on developerWorks that may interest you.

http://www.ibm.com/developerworks/web/library/wa-aj-dojogrid/index.html

Cheers.

S.Jones
I can't find anything about automated indexing, but it looks like a nice library - thanks for the link!
Chris Lercher
A: 

I'd suggest you reconsider your design, browsers are not the most responsive of applications on a good day for a variety of reasons. In addition to this the design of embedding a database in the browser session (no matter how light) is placing explicit demand on the thin client. The thin client may or may not have the resources to support the requirements.

If you have explicit control over the thin clients (corporate environment?) it would be best to leverage some desktop technologies or applets (java?) outside of the immediate browser context.

Ashley Walton
No control over the clients. Anyone can use it, for free (as long as they have JavaScript enabled, but that's required for GWT apps anyway). The performance is not a problem in modern browsers, as long as the model isn't too large, and as long as you use indexes (as has been done by others). In fact, it's a lot faster for users, when the model can be queried locally. Moreover, it saves a lot of bandwidth. The model is strongly interlinked, and can be queried in many ways, so it's really in the best interest for the user. And keeping the model local is IMO the way to go for modern web apps.
Chris Lercher
I assume you aren't worried about mobile platforms that may be resource constrained, sounds interesting though so future please feed back how the solution evolves
Ashley Walton
+4  A: 

XBSDB seems to be good library for client-side db plus indexing solution.

Ayaz Alavi
@Ayaz: This is absolutely great! I can't believe, I didn't find it (and that it's only on 4th page on Google when searching for javascript database). It's about 32k gzipped JavaScript - I wonder, how much smaller this could be, if it were built on GWT (assuming that many classes like HashMap are already loaded...) But I think, it's a wonderful project!! Thanks for the link.
Chris Lercher
:) no problem, just did a quick google search ;). Am I getting the bounty?..lolz, thats a bit greedy.
Ayaz Alavi
thanks a trillion, I marked 1K.
Ayaz Alavi