Fork me on GitHub

@petrus: That or you can hack together your own solution. I ended up writing a simple sync solution where I create a filtered database for each user and then stream the datoms to them over sente to datascript. I’m not sure how to do optimistic writes though.


How would you go about comparing two datascript database snapshots (d/db conn) in time? I’m want my user to be able to edit data and then I want to send the :db/add and :db/retract`s to the server to apply the changes. Datomic has d/since, but it doesn’t appear that datascript does.


@nikki: Just curious. Isn’t it possible to transpile datascript to Objective C (maybe And it already runs in Java so I guess you could get it working in Android?


but i'd still want to use it from JS running in JSC


@seantempesta if both snapshots are created by the same process – you could diff based on tx-ids


@misha: Yeah, I’m looking at that. Will that cover retractions though?


or, what I did: you ds/listen! and just collect txs as db lives on, sending collected tx periodically to server with or w/o reducing them


ds/listen! will cover retracts usecase, but will be a bit more noisy for "hot" attributes: if you change same [e a] multiple times in a row, you'll get multiple txs instead of a single one. But this is reducible, since you have schema available


hmm, not sure I follow the reducible part.


say you have cardinality one :foo/bar. changing it's value from :a to :b to :c will generate [[- :a][+ :b][- :b][+ :c]], it can be reduced to just [[+ :c]] (if you don't care about separate transactions for undo/analytics purposes)


new, deleted or changed*


You could use == for faster comparison of numbers.


(`(== (count achunk) (count bchunk))`)


I haven't gone deeper than this, but maybe it's possible to create something "queryable" from the diffs of the chunks? I don't know. Just re-running the queries when there's been a change has worked fine for me so far


Which queries? When is this diff to detect change (this is just boolean, right?) more suitable, than ds/listen! ?