What’s new in IndexedDB 2.0?
hacks.mozilla.org
hacks.mozilla.org
And even if somebody went in and specified all of SQLite's features, then there would still be the issue that any accepted web standard needs two independent implementations, meaning that one of the browsers would have had to clean-room reimplement SQLite.
And finally, there would be the question of what to do as SQLite involved. What would browsers do as SQLite gains features or changes behaviour? Keep the old version of SQLite around for JS? Freeze the whole browser on the old version of SQLite?
I agree though that WebSQL was much more convenient and useful than IndexedDB.
I'm not sure if that ever happened.
If SQLite gets new features you do the same thing you do with other specs. If it makes sense to expose them, you update the spec.
Furthermore, outside of the TLS case, most of those are still within the ballpark of reason -- feasible to reimplement even in a small group. That's definitely something to be considered -- it's not just a case of if it's possible, but whether at all it's even realistically feasible for most people to reimplement.
Replacing WebSQL is on a completely different level of difficulty compared to these. Not only is it massively more complex to implement, there really is only one implementation, so it's pretty much impossible to reimplement exactly to spec, with the same kind of performance/usability characteristics -- without just doing a clean-room analysis of SQLite.
> If SQLite gets new features you do the same thing you do with other specs. If it makes sense to expose them, you update the spec.
It's never that easy. What happens if SQLite changes the way a feature behaves, even for good reason? The developers aren't beholden to browser devs, so this is within their right. What happens if they don't change something and a bug is then "enshrined" as part of the implementation -- or what if someone wants to make a change like, I dunno, actually checking the types of values you insert into the DB?
I do think WebSQL was promising and it does suck it was axed. But I think it was axed for a fairly sound reason, even if humans aren't always perfect robots who make exactly perfect decisions in similar instances (e.g. a similar difficulty argument could be made against TLS, although we're already waaay past that point).
Actually, we are beholden to application developers of all types. It's part of the SQLite social contract. SQLite does not change in incompatible ways. New features are added, performance is enhanced, but we work hard to not break any of the millions and millions of diverse applications that use SQLite.
I just started messing with it a few days ago, and so far, you can only query on indexed fields, and only one at a time, and the only allowed conditions are <, <=, >, >=, and =. If you want any kind of compound conditions, you're going to have to do it manually. There's no documentation for how to sort, and it only supports sorting on a single indexed key at a time. Seriously, I had to dig up and read the Chrome source code to figure out how to specify the sort order of a cursor (Hint: It's a string, like 'next', 'prev', not an IDBCursorDirection as the MDN docs mention but don't describe). Don't even bother asking about aggregates, projections, etc.
When I read the linked document, I couldn't help but think - honestly, they're calling being able to change table and index names a headline 2.0 feature? How about at least documenting sorting in queries? Much less supporting querying on multiple fields, on non-indexed fields, using AND and OR, etc. This feels like a 0.2 product to me.
> I still feel that the api is a lot more complicated
> than it has any right to be. WebSQL for example was nifty
From the Web SQL Database W3C Working Group Note, 18 November 2010 (https://www.w3.org/TR/webdatabase/): "The specification reached an impasse:
all interested implementors have used the same SQL backend (Sqlite),
but we need multiple independent implementations
to proceed along a standardisation path."
I would imagine it's no small project to reimplement an SQL interpreter from scratch.Mozilla has said that IndexedDB is an API at a lower level than SQL:
"IndexedDB . . . allows for a wide number of use cases.
. . . wrapped by JavaScript libraries;
for instance, there’s plenty of room for a CouchDB-style API on top . . .
it would also be very possible to build a SQL-based API on top . . . "
--- https://hacks.mozilla.org/2010/06/beyond-html5-database-apis...Although you can use the IndexedDB directly, it sounds like even they admit that you probably would want to use a higher-level library much of the time --- and that one of those libraries could be SQL, if anyone wants to write one.
In that article they also give some of the reasons they don't think the W3 should try to weld SQL directly onto the standard. I think they make some thoughtful points. Although I love SQL, I have to admit that it's one of those things that sounds great from 10,000 feet but the devil is in the details.
select * from table
How hard can that be? But it's when you dive into all the nitty gritty and differences among database brands, and how the spec itself is ultimately ambiguous on certain things, plus the astronomical amount of work it would be, that I think their solution is sound.http://caniuse.com/#feat=indexeddb
https://developer.apple.com/library/content/releasenotes/Gen...
https://github.com/localForage/localForage/issues/604#issuec...
https://github.com/google/lovefield
Explanation here: https://www.youtube.com/watch?v=S1AUIq8GA1k
It works fine. Transactions prevent conflicts. And you can even do schema upgrades because there is built-in versioning, and it provides events to let you handle when a version change occurs in another tab.
Also, is there some eventing mechanism to push messages through the database between tabs?
No, you have to do that yourself.
It's been a while since I looked into this, but I remember this being my conclusion.
https://developer.mozilla.org/en-US/docs/Web/API/IDBFactory/...
"The method returns an IDBOpenDBRequest object immediately, and performs the open operation asynchronously."
The 2.0 spec is just a bunch of minor changes. Promises will be a big change - although I would argue it's way more important than all this other stuff combined.