You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
currently we provide a vector shorthand that expands into datomic attribute map
namely, we have the #attr pattern: [ident type cardinality ?(unique | component) ?pred]
*if type is db.type/ref then third index is a db/isComponent boolean otherwise it is a db.unique value.
This works great because the majority of attributes require an ident, type, and cardinality so it's easy to pick up on the pattern, and for other cases we provide other reader literal shorthands (i.e. #ent, and #spec.)
Note, I also considered providing shorthands for the :db value forms but every alternative considered loses semantic meaning. i.e. the keyword :one is less semantically meaningful than :cardinality/one and we can't just do :cardinality/one because that implies it is a non-namespaced attribute, which it's not.
Of the fourth alternatives below (fourth one being default datomic attribute map), the third variation offers succinctness without losing important meaning.
-#attr [:user/username :string]
-#attr [:user/username :type/string cardinality/one]
-#attr [:user/username :db.type/string :db.cardinality/one]
-{:db/ident :user/username :db/type :db.type/string :db/cardinality :db.cardinality/one}
One alternative that would have been great is if namespaced keywords were allowed in EDN files, i.e. ::type.one could be expanded into db.type/one but unfortunately that's not allowed so for now we'll stick with fully specifying datomic attribute values.
The text was updated successfully, but these errors were encountered:
currently we provide a vector shorthand that expands into datomic attribute map
namely, we have the
#attr
pattern:[ident type cardinality ?(unique | component) ?pred]
*if type is
db.type/ref
then third index is adb/isComponent
boolean otherwise it is adb.unique
value.examples:
-
#attr [:user/username :db.type/string :db.cardinality/one :db.unique/identity]
-
#attr [:note/owner :db.type/ref :db.cardinality/one true]
This works great because the majority of attributes require an ident, type, and cardinality so it's easy to pick up on the pattern, and for other cases we provide other reader literal shorthands (i.e.
#ent
, and#spec
.)Note, I also considered providing shorthands for the
:db
value forms but every alternative considered loses semantic meaning. i.e. the keyword:one
is less semantically meaningful than:cardinality/one
and we can't just do:cardinality/one
because that implies it is a non-namespaced attribute, which it's not.Of the fourth alternatives below (fourth one being default datomic attribute map), the third variation offers succinctness without losing important meaning.
-
#attr [:user/username :string]
-
#attr [:user/username :type/string cardinality/one]
-
#attr [:user/username :db.type/string :db.cardinality/one]
-
{:db/ident :user/username :db/type :db.type/string :db/cardinality :db.cardinality/one}
One alternative that would have been great is if namespaced keywords were allowed in EDN files, i.e.
::type.one
could be expanded intodb.type/one
but unfortunately that's not allowed so for now we'll stick with fully specifying datomic attribute values.The text was updated successfully, but these errors were encountered: