3 ms·
I've been playing around with a Graph database OGM (G is for graph) https://github.com/emehrkay/Gizmo https://github.com/emehrkay/Gizmo and its event sourcing i
by emehrkay 11y ago
I've been playing around with a Graph database OGM (G is for graph) https://github.com/emehrkay/Gizmo https://github.com/emehrkay/Gizmo and its event sourcing is a very simple implementation of what Fowler described in a post a while back.
Graphs are simple which made this exercise even easier:
entity(vertex) -> edge($RELATIONSHP) -> entity(vertex)
vertices are simple, unstructured maps, so in my library you simply add a source entity when saving and all of the changes will be tied to that source.
Pseudo:
user = get_user('emehrkay')
reply = get_reply($THIS_CONTENT)
user_reply = connect(user, reply, 'posted')
save = save(user_reply, source=user)
This would create a graph like this
user('emehrkay') -> posted -> reply($THIS_CONTENT)
reply($THIS_CONTENT) -> event -> event("reply's changes")
event("reply's changes") -> source -> user('emehrkay')
"emehrkay made these changes to the reply"
Very fun/cool stuff. I haven't had the need to query against the history yet, so I don't know how simple it would be or if it were possible to set a time and query the whole graph against that time (like in the example posted in another comment)