4 ms·
I also do with people stopped saying localStorage is 'too slow', its certainly not a fully fledged database, but its almost perfect as a cookie replacement, whe
by daleharvey 15y ago
I also do with people stopped saying localStorage is 'too slow', its certainly not a fully fledged database, but its almost perfect as a cookie replacement, where you werent storing 5MB of data in cookies anyway.
I spent some of this weekend playing with IndexedDB, its very hard to get into at the moment, mostly due to the different implementations across mozilla / chrome, but there is some complexity that doesnt look easily solved by a wrapper, just understanding what is meant by onupgradeneeded / setversion seems needlessly complex.
Other problems include "Indexed DB is not available in private browsing mode", how are people supposed to build offline webapps when the applications can easily be prevented from accessing their own data?
IndexedDB is nice, but its quite opinionated and complex, I think browser vendors needs to think about what lower level constructs can be given to developers in order to create their own databases, and as much as I dislike the thought of SQL client side, I think it was probably a mistake to shoot websql so early on, sqlite is the standard of embedded databases.
- MatthewPhillips 15y ago> I spent some of this weekend playing with IndexedDB, its very hard to get into at the moment, mostly due to the different implementations across mozilla / chrome, but there is some complexity that doesnt look easily solved by a wrapper, just understanding what is meant by onupgradeneeded / setversion seems needlessly complex. This is definitely an annoyance but it is pretty easy to overcome: const DB_VERSION = 1; req.onupgradeneeded = function(e)... req.onsuccess = function(e) { var db = e.target.result; if(db.setVersion && Number(db.version) !== DB_VERSION) { var dbReq = db.setVersion(DB_VERSION); dbReq.onsuccess = function(e) { req.onupgradeneeded(e); req.onsuccess(e); }; return; } // You can use db now. }; > Other problems include "Indexed DB is not available in private browsing mode", how are people supposed to build offline webapps when the applications can easily be prevented from accessing their own data? Good point, are there any queues to the developer that the browser is running in private mode? If so I think we just need to inform the user. > IndexedDB is nice, but its quite opinionated and complex, I think browser vendors needs to think about what lower level constructs can be given to developers in order to create their own databases, and as much as I dislike the thought of SQL client side, I think it was probably a mistake to shoot websql so early on, sqlite is the standard of embedded databases. There are going to be a lot of IndexedDB libraries once it becomes supported (in the modern spec) by all browsers. There will be libraries that give you a simple key/value store like localStorage does today (I'm working on one of these), there will be libraries that let you write SQL, and probably every other paradigm that people enjoy.
- ars 15y ago> Other problems include "Indexed DB is not available in private browsing mode", how are people supposed to build offline webapps when the applications can easily be prevented from accessing their own data? I think you are confusing private browsing with offline mode. Private browser is when the user specifically doesn't want the application to have any access to previously stored data, and doesn't want the application to store anything either.
- daleharvey 15y agoI wasnt confusing private browsing / offline mode, and I do understand that private mode ensures that data is temporal, but disabling the feature, instead of just cleaning it up when the use leaves private mode, just means another edge case for developers to have to handle, or for them to just ignore private mode, which doesnt make sense for a lot of 'desktop' like apps in the browser
- ars 15y agoAre you saying that in private mode you can't use index db at all? If so, then yes I agree with you.
- daleharvey 15y agoThat is what the mozilla documentation suggests @ https://developer.mozilla.org/en/IndexedDB/Using_IndexedDB https://developer.mozilla.org/en/IndexedDB/Using_IndexedDB "Obviously, browsers do not want to allow some advertising network or malicious website to pollute your computer, so browsers prompt the user the first time any given web app attempts to open an IndexedDB storage. The user can choose to allow or deny access. Also, IndexedDB is completely disabled in the privacy modes of browsers (Private Browsing mode for Firefox and Incognito mode for Chrome). The whole point of private browsing is to leave no footprints, so attempting to open a database fails while in this mode." Testing it in chrome it looks like it is working fine, I should know better than to trust the docs :)