arturo-lang / grafito

Portable, Serverless & Lightweight SQLite-based Graph Database in Arturo
MIT License
145 stars 8 forks source link

Add (optional) properties to edges #38

Closed drkameleon closed 11 months ago

drkameleon commented 11 months ago

Until now, Grafito offers properties/data only for nodes.

However, adding this possibility for edges too would be really interesting and useful (most graph databases support, plus it could open the way for things like "weights graphs", etc), so... let's see how this goes! 🚀

P.S. Syntax-wise, especially in queries, this might get a tiny bit complicated, but remains to be seen!

drkameleon commented 11 months ago

And... ready to merge! 🚀


What we've managed in this PR

In a few words

Now, not only nodes by edges may have properties/data as well

How do we set set this data?

Let's say we have our helpers in place (e.g. lemma, etc):

lemma ~> 'means .:[as: "noun"] someMeaning

(.: is the part where we are setting the edge's - means's - properties, using a weird bug-or-feature of Arturo: empty attributes - yes, .: is actually the "" attribute being set to [as:"noun"] ⚠️ )

How do we query this data?

lemma [
    means: |> [][
        as: "noun"
    ]
]

Word of caution: The above (the syntax mainly) may change. So, don't trust it 100%. (Better ask me, if you want to play and have questions - I'll be more than glad to help, if I can). Plus, the whole project is still in in-the-making stage, so different things could change. Sure thing is it needs an extreme cleanup & re-organization, which I hope to find the time for soon! 🚀