datascript

Immutable database and Datalog query engine for Clojure, ClojureScript and JS
Oliver George 2020-05-23T02:20:20.045100Z

Anyone else crying out for a persisting Datascript? I'm guessing IndexedDB is the sensible (if intimidating) API to build on and living with async queries would mean keeping a full history to provide "point in time" queries.

Oliver George 2020-05-23T02:20:55.046Z

I'd also love it to persist in React Native which doesn't seem to provide IndexedDB.

adamtait 2020-05-23T22:21:49.058600Z

@olivergeorge what direction are you leaning? In my exploration - AsyncStorage seems well supported but has a size limit. FS & SQLite have less support but fewer limits.

Oliver George 2020-05-23T23:43:43.059300Z

For now I’m using SQLlite.

Oliver George 2020-05-23T23:44:05.060Z

AsyncStorage limits are solvable now by the way.

1👍
Oliver George 2020-05-23T23:47:37.060500Z

It doesn’t suit me because pulling everything into memory and deserializing is slow. Also the variety of access patterns I need makes it tricky to break things up into convenient documents.

Oliver George 2020-05-23T23:47:55.060800Z

SQL queries are friction but solvable

Oliver George 2020-05-23T23:48:12.061100Z

It’s just a shame that I can’t use the same techniques on the web app version of the same application

1👏
Oliver George 2020-05-23T02:21:58.047Z

(holding large datasets in memory on mobile devices seems like a design flaw but I've not tested the impact on performance)

2020-05-23T07:20:19.047700Z

Is it not what datahike is about?

lilactown 2020-05-23T15:56:42.048Z

sqlite seems popular on mobile

lilactown 2020-05-23T15:57:45.049500Z

@olivergeorge I don’t see much to be done tbh. I think that you could easily serialize the datascript db and put it in indexeddb or localstorage (depending on size / etc.)

lilactown 2020-05-23T15:58:15.050200Z

but I think the flow would be to then pull out the whole db and deserialize to do queries

2020-05-23T18:37:41.052Z

@olivergeorge This is exactly what Datahike is about. Only thing missing right now is a durable mode on the front end. Means rewriting the query engine to be async (since no blocking in JS), which is some work, but I believe the team is queueing that up soon.

2👍
2020-05-23T18:38:40.053Z

@lilactown You can do what you are suggesting if you don't have too much data, but that way you still have to hold things in memory. What's being worked on would not be limited in this way.

lilactown 2020-05-23T18:44:48.054500Z

it’s a tradeoff, but I’m struggling to think of a time when have had so much data that I would rather pay the performance cost of going to disk

lilactown 2020-05-23T18:45:46.055400Z

I’m sure for some niche cases that’s true, but the majority of webapps have nowhere near those kinds of requirements, which is why I think the datomic-esque “load the db in memory and query it” makes more sense

lilactown 2020-05-23T18:50:54.056900Z

you could probably do something similar to datomic where you cleverly store the EAVT values in indexeddb to allow an efficient as-of without duplicating data

lilactown 2020-05-23T18:51:25.057500Z

my hunch is just that you don’t want to hit indexeddb for every query. I’m interested to know if I’m wrong!

teodorlu 2020-05-23T20:58:12.058Z

Perhaps stupid question: can I browse a datascript database with REBL?

teodorlu 2020-05-23T21:20:04.058300Z

Open PR asks for this: https://github.com/tonsky/datascript/issues/313

adamtait 2020-05-23T22:21:49.058600Z

@olivergeorge what direction are you leaning? In my exploration - AsyncStorage seems well supported but has a size limit. FS & SQLite have less support but fewer limits.

Oliver George 2020-05-23T23:43:43.059300Z

For now I’m using SQLlite.

Oliver George 2020-05-23T23:44:05.060Z

AsyncStorage limits are solvable now by the way.

1👍
Oliver George 2020-05-23T23:47:37.060500Z

It doesn’t suit me because pulling everything into memory and deserializing is slow. Also the variety of access patterns I need makes it tricky to break things up into convenient documents.

Oliver George 2020-05-23T23:47:55.060800Z

SQL queries are friction but solvable

Oliver George 2020-05-23T23:48:12.061100Z

It’s just a shame that I can’t use the same techniques on the web app version of the same application

1👏
Oliver George 2020-05-23T23:49:57.062Z

Yeah it’s problematically slow to load given the data I have on mobile. Also holding everything in memory on mobile is a questionable.