Thanks for the detailed answer @quoll. Weighted edges with a multigraph should be good enough for what I'm trying to do at the moment - though my use-case definitely isn't important enough for to you move anything up your to-do list(!)
Re: how to access edge properties - I'm probably not qualified to answer, I'm very new to Clojure, never used Datomic and have only been looking into asami for the past ~24 hours.
Coming from Neo4j, i've always found the Cypher syntax to be very intuitive
MATCH (p1:Person {name:'alice'})-[f:FRIEND]-(p2:Person {name:'bob'})
RETURN f.date
But no idea how to turn that into something Datomic-y...
Stick another variable in front of the edge to let you use it later on in the :where
? 🤷
'[:find ?date
:where [?p ?f:friend ?p2 ]
[?p :name 'alice']
[?p2 :name 'bob' ]
[?f :date ?date ]
That’s possible. I’m a bit uncomfortable pulling apart symbols more than I already do.
One other approach is metadata on the pattern. After all, it’s not the :friend
attribute that you’re talking about, it’s the edge between 2 nodes that uses the :friend
attribute for the edge
'[:find ?date
:where ^?f [?p :friend ?p2 ]
[?p :name 'alice']
[?p2 :name 'bob' ]
[?f :date ?date ]]
Right now, it’s trivial to just make it: [?p :friend ?p2 ?f]
But just because it’s easy doesn’t mean I should do it that way
There are some incompatibilities between Datascript, Datomic and Asami. If I did this final one (the easiest one), then I would be creating a much bigger incompatibility
you could always use a map 🙂 [?p :friend ?p2 ?f]
-> {:entity ?p :attribute :friend :value ?p2 :edge ?f}