Fork me on GitHub
#datascript
<
2020-07-31
>
David Pham09:07:53

Is there a way to have historical version of the database in datascript?

David Pham09:07:02

Something like two transactions ago?

metasoarous17:07:06

Datascript Databases are persistent datastructures, just like regular ol clojure data

metasoarous17:07:45

So if you take d1 , use (d/with-tx ...) (or whatever; forget the exact function), you get a new db d2 which shared structure with d1 , but remains a separate referenceable value.

metasoarous17:07:37

Datascript conn s are just simple atom containers with just a bit of extra metadata.

metasoarous17:07:02

It doesn't do any historical tracking other than what an atom would do. But you could easily come up with your own state management that kept references to snapshots on whatever basis you like.

metasoarous17:07:58

If you got fancy enough, you might even be able to bake it into a regular conn atom's metadata, the way that posh does.

metasoarous18:07:06

More straightforward: just write a couple of api functions for abstracting over all of this (`http://my.wild.app/transact`, etc)

👍 3
lilactown23:07:42

is it possible to transact something like:

{::folder/id "asdf"
 ::folder/parent "jkl"}


{::folder/id "jkl"
 ::folder/children [,,,] ;; something that will associate anything that declares "jkl" as a parent
 }
?