4 ms·
That's how every langauge with immutable data structures works. What makes this one special?
by wereHamster 11y ago
That's how every langauge with immutable data structures works. What makes this one special?
- dwwoelfel 11y agoWith this one, the database is an immutable value, so you can hold on to old versions of it. Here's an incomplete example of how you could implement optimistic updates: tx_report = datascript.transact(db_conn, [{:key "value"}]); set_db_to_render_from(tx_report.db_after); send_report_to_server(tx_report, function(error) { set_db_to_render_from(tx.report.db_before); });
- sheepmullet 11y agoNormally when you update a row in a database you lose the ability to access the previous values. E.g. If you update your address it overwrites your previous address With datomic you are just adding a new fact. My address is now x. This has a lot of nice properties. I can now easily write a query to tell me your previous 5 addresses, rolling back is easy, you can get amazing and scalable read performance, etc etc In the past we have either had to hand roll our own features (e.g. Have a table of past addresses, or add date columns to specific tables) or rely on error prone/brittle techniques like using audit tables, source control, or transaction logs. Datomic makes it easy!