Comments (6)
+1 to proposal weight ;-)
from datascript.
DataScript DB is a persistent data structure. Database mutation is build in terms of pure functions. You can get full DataScript experience without touching atom/conn/listeners part: check out empty-db
and with
. For example, with
works just like transact!
except that it takes db and returns db, being, in fact, a pure function. Queries run over plain DB values, not over connections.
There’s then a thin layer (optional, in fact), wrapping this DB into an atom (literally) and providing transact and listener facilities. It’s build on top of the same immutable, pure primitives.
Database swapping is atomic, there’s no “temporary db states”. Atom is atomically swapped from db-before to db-after when using transact!
.
You can build your own mutation layer quite simply, just by using (swap! db-atom with ...)
instead of transact!
. You’ll lose txReports, but overall experience will be the same.
So the only question remains, why TxReports?
Atom’s watch
fn gives you just value before and after, but it does not capture the change. TxReport solves exactly that problem: when using transact
or transact!
, it captures normalized deltas from db-before to db-after. Why may we need that?
First, to monitor DB: you can run Datalog queries over tx-data to know when the part you’re interested in have changed. It’s much faster than run the same query over full DB. (See here, “Transaction format happens to match database format...”).
Second, it makes a great server sync format. You may add generic listener to DB that will mirror all changes to server backend for durability.
There’s no incidental complexity to it. It’s actually just more detailed version of atom, where not only value before and value after, but change itself is also data. All the data-oriented benefits apply.
from datascript.
Thank you for taking the time to state your design ideas so clearly, I think it will make a great start for a datascript
wiki page 👍
I generally agree with everything you said and probably I should have read your code more carefully and expressed myself better. As you say, transact!
, create-conn
and the likes are a thin layer on top of a persistent data structure: maybe the usage examples could help a future reader first introducing the purely functional operations on datascript and leaving the atom manipulation at the end of the README as an optional nice-to-have.
I especially liked your explanation for TxReports. But what if the latest tx-data is included as yet another key inside datascript
data structure? That way every new database version would be self-explicative.
from datascript.
m.b. not key inside data structure, but in metadata?
from datascript.
Well yeah, alongside av
, max-eid
and the other keys
from datascript.
What’s wrong with the way it is right now?
from datascript.
Related Issues (20)
- Improve Skypack "Package Score" for better devX HOT 2
- Attribute of composite tuple starting with colon is not working in js HOT 1
- How to hotfix aot code ?
- How to hot fix aot code?
- Rules - Required bindings doesn't evaluate correctly HOT 1
- Datascript101 link is dead HOT 1
- `get-else` fails when passed a lookup.
- `entity` returns entities for ids that don't exist HOT 2
- Is there any doc to demo idiom way to implement pagination in datascript? HOT 4
- Upsert of datom with composite tuple containing lookup ref fails HOT 5
- Recursive reverse lookups not working quite like it should HOT 1
- Lookup ref in composite tuple during upsert HOT 1
- do we have double vector type? HOT 2
- `:xform` is not called on ref attributes HOT 2
- Query performance with rules is much worse than "equivalent" inline clause HOT 3
- Ability to pass multiple functions into query HOT 1
- Index usage doesn't match datomic behavior and appears to be much less efficient HOT 1
- Inaccurate temporary IDs after transit deserialization
- Unable to resolve tempids on :db.unique/identity refs HOT 2
- Handling of BigDecimal
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datascript.