threatgrid / asami

A graph store for Clojure and ClojureScript
Eclipse Public License 1.0
637 stars 29 forks source link

Suggestions: Initial values and identity #97

Closed timothypratley closed 4 years ago

timothypratley commented 4 years ago

This is a brief "getting started" experience report and some suggestions. My apologies if this is not the right forum, happy to engage via a different one if more appropriate.

Asami is interesting to me because: a. Query optimization b. Schemaless c. Graph interface d. Performance relative to DataScript e. Joel said it was cool

The getting started information was clear accurate and got me going quickly. So far I really like Asami.

Two things I found confusing:

  1. Initial values:

When I attempt to transact an attribute annotated with ' that does not have a previous value, it fails. I must first transact a single attribute without the ' annotation, then subsequently use the ' to have only one of them. Why am I not allowed to set the initial value in the same way as subsequent values?

  1. Identity

Datomic and DataScript have a Lookup Ref syntax[:my/attr "value"] that can be substituted for an entity. This didn't work in Asami. Asami's notion of identity seems to be different... I think Asami identities are more like global identifiers and it is up to me to deal with entity collision. For example, if I wanted to identify users by email address I might make their identity be the conjunction of the word "email" with their actual email address. This feels a little redundant, but maybe that is necessary in a schemaless world as there is no schema to determine what attributes are identities and what are not.

quoll commented 3 years ago
  1. This should be allowed, so I'll add it. The reason it doesn't work right now is that it's an update, meaning that it looks for that value, removes it, and then adds in the new value. When it doesn't find the expected value, then I should just skip the removal.
  2. Asami doesn't have that syntax, no. I can consider adding it, but as you figured, it can be an issue when you don't have a schema.
timothypratley commented 3 years ago

Thank you! FWIW I think it would be nice if the behavior of [:my/attr "value"] was to attempt to lookup an entity (regardless of identity) and upon finding multiple throw an error.