Moor: Web support planned?

Created on 19 Jun 2019  路  8Comments  路  Source: simolus3/moor

We are currently developing an app that uses Flutter for mobile and AngularDart for Web.
It would be cool if we could have an abstraction for creating queries and also an abstraction for the underlying framework such as SQLite or AlaSQL.
Are there already any plans?
How much effort would this be?

Most helpful comment

sql.js is looking more promising indeed, I managed to get a minimal prototype with persistence working. What still needs to be done:

  • [x] Transactions
  • [x] Batched statements
  • [x] Returning the insert id for INSERT statements
  • [x] The new "before open but after migrations" callback from version 1.5
  • [ ] Tests!

All 8 comments

I've already taken a quick look at AlaSQL and considered adding web support for moor using that library in the past. The effort would depend entirely on how different AlaSQL is to sqlite, I didn't take an in-depth look yet. I'll do that soon.

Started some work for this on the web branch, I hope to make a working prototype out of that next week.

Great news, let me know when it's ready. I will have a look at it with my team then! :)

Sorry for the delay on this. Unfortunately, AlaSQL has some issues which makes it really hard to work with. It doesn't support some sqlite functions, doesn't persist table changes (so default values will be gone when reloading the page) and doesn't really support migrations. I've used some hacky workarounds to counter some of these problems, but the whole thing is still very unreliable. It also doesn't seem to be very well maintained, having many important issues open for a long time.

I'll try sql.js next. It requires webassembly, but that should be available on most modern browsers anyway. The big advantage is that it will behave exactly the same as sqlite, although persisting changes is a bit tricky at the moment.

sql.js is looking more promising indeed, I managed to get a minimal prototype with persistence working. What still needs to be done:

  • [x] Transactions
  • [x] Batched statements
  • [x] Returning the insert id for INSERT statements
  • [x] The new "before open but after migrations" callback from version 1.5
  • [ ] Tests!

So this landed in develop and will be a part of moor 1.6! I've written some documentation on how to use moor for the web here.

If you want to try this out now, you'll need to use a dependency override pointing to the moor/ folder on the develop branch in this repo. Also, don't consider the format in which the database is stored finalized yet, it will be changed (which breaks existing databases) before version 1.6 is released publicly.

Here is the source code for a simple todo app built using moor and flutter for web. It's deployed here. You can see the sql statements sent in the console. Web support is not optimized for performance yet, so it can take a while to show/add entries.

Really cool 馃挭馃徏! Thanks for the effort 馃檹馃徎!
I will try it out and give you feedback asap.

FYI, the breaking encoding change is now on develop - the way databases are stored is final now, but you need to localStorage.clear() pages where you've already used moor for web.

Also, web support now lives on beta and I'll hopefully release it on pub later this week. Closing this issue now as web support is done. If you run into any issues, please let me know by opening another issue, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

omidraha picture omidraha  路  3Comments

Beloin picture Beloin  路  4Comments

tony123S picture tony123S  路  4Comments

johrpan picture johrpan  路  4Comments

simolus3 picture simolus3  路  4Comments