DEV Community

Discussion on: Choosing the right frontend database for a single page application

Collapse
 
radex profile image
Radek Pietruszewski

Hey Johannes,

Radek here - main author and maintainer of WatermelonDB. It's really interesting to hear your thoughts on it because most of your complaints are EXACTLY what I've been working on fixing over the last couple of weeks!

IndexedDB is just stored as one big string

Not anymore! I've completely rewritten LokiJS's IDB adapter to store things in little chunks: github.com/techfort/LokiJS/pull/808 and are working on further performance improvements: github.com/techfort/LokiJS/pull/811 — it's actually not one record per IDB object, because IDB is slow at this. It's more profitable (for mass insert and reading) to store objects in chunks than one-per-record or one-huge-chunk

Some issue with fast consecutive writes (but that might have been me using it wrong)

That's true, there has been some performance regressions, and it was never 100% optimized. This is changing. I've improved fast consecutive writes on web by 6x, and on iOS by a ridiculous 23x. Further 5x on top of the 23x is coming to iOS, and a huge perf upgrade to Android as well.

Strongly focused on react

That's true at the moment, but that's something I hope the open-source community will improve.

WatermelonDB itself is actually 100% React-agnostic at this moment. The part that connects 🍉 to React (withObservables) is by design a separate component. It's what we use, so it's what we documented and published, but in reality, the only thing that's missing to use WatermelonDB in any framework is a small bit of code to connect RxJS Observables to your components. Easy!

Typescript Errors

That one I have no updates on - TypeScript types are entirely community-led, and I encourage you to contribute to that effort!

Collapse
 
dzcpy profile image
dzcpy

I Really hope that it can support encryption on both mobile platforms and desktop. There's a pull request but it's been inactive for so long.

Collapse
 
johannesjo profile image
Johannes Millan • Edited

Hey Radek,

thanks for your reply! That's really great news! I really like what WatermelonDB hast o offer. I'll definitely give it another go.

it's actually not one record per IDB object, because IDB is slow at this. It's more profitable (for mass insert and reading) to store objects in chunks than one-per-record or one-huge-chunk

I got the same feeling during my experiments. It's a shame that this seems to be the case. Would be cool if IndexedDB would behave more like a real database rather than a fancy version of localstorage.

The changes don't seem to be available in the latest npm version yet. How would you recommend to go about testing them (which of the new pre-releases should I use)?

Collapse
 
radex profile image
Radek Pietruszewski

I got the same feeling during my experiments. It's a shame that this seems to be the case. Would be cool if IndexedDB would behave more like a real database rather than a fancy version of localstorage.

Agreed. It's a shame that WebSQL got ditched -- it was very powerful, and fast, too.

The changes don't seem to be available in the latest npm version yet. How would you recommend to go about testing them (which of the new pre-releases should I use)?

Try v0.15.0-8 -- and if that doesn't work, v0.15.0-7 — you should be able to insert tens of thousands of records per second with the latest changes -- but even more optimizations are coming.

Thread Thread
 
johannesjo profile image
Johannes Millan

Thank you! I'll give it another go!