Hodur is a domain modeling approach and collection of libraries to Clojure. By using Hodur you can define your domain model as data, parse and validate it, and then either consume your model via an API or use one of the many plugins to help you achieve mechanical results faster and in a purely functional manner.
The amount attribute is defined as :foo.tx/amount when it's a
spec, and just :tx/amount in the db. I want to have the same
identifier for the same attribute everywhere in my clojure code, so
amount would be called :foo.tx/amount everywhere. I also ran into this
same issue when writing a plugin to generate a json (de)serializer.
(def meta-db
(engine/init-schema
'[^{:spec/tag-recursive true
:datomic/tag-recursive true
:json-serde/tag-recursive true}
tx
[^Integer amount]]))
(hodur-spec/defspecs meta-db {:prefix :foo}) ;=> [:foo.tx/amount :foo/tx]
;; When I write my own plugin it needs the prefix arg
(def parse-json
(hodur-json/parser meta-db :tx {:prefix :foo}))
;; To use the same qualified name everywhere, I wrote a wrapper
(def schema
(my-hodur-datomic-wrapper/schema meta-db {:prefix :foo}))
Now I need to pass the prefix a bunch of places in the code. It would
be better to specify the prefix together with the rest of the data
model.
I think most plugins are going to want to refer to a canonical, unique,
qualified name for each attribute, so I feel like this
should be the responsibility of hugin-engine.
When using hodur I ran into an issue with names.
The
amount
attribute is defined as:foo.tx/amount
when it's a spec, and just:tx/amount
in the db. I want to have the same identifier for the same attribute everywhere in my clojure code, so amount would be called:foo.tx/amount
everywhere. I also ran into this same issue when writing a plugin to generate a json (de)serializer.Now I need to pass the prefix a bunch of places in the code. It would be better to specify the prefix together with the rest of the data model.
I think most plugins are going to want to refer to a canonical, unique, qualified name for each attribute, so I feel like this should be the responsibility of
hugin-engine
.The api I want is the following:
When no ns-prefix is specified, default to the current namespace, like the spec plugin.
On the meta-api side, this would involve adding a
:<node-type>/qualified-name
to each entity.The downside to all this is that it would be a breaking change for the datomic plugin and maybe others.
What do you think? How would you structure the namespaces?