replikativ / replikativ/datahike
Idiomatic way to express 'sum type' (db/valueType) spec?
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 1.9k
- Forks
- 117
- Avg merge
- 10h 7m
- Merged PRs (30d)
- 111
Description
I'm trying to programmatically convert json-schemas into datahike schemas.
Please note that I don't have a particular model/schema in mind for my use-case. I just want to generate a sensible, predictable datahike schema from an arbitrary json-schema.
An issue I have is that it isn't obvious to me how to convert sum-type-like definitions like so:
{"type": ["integer", "string"]}
In this case, a scalar type can be either an "integer" or a "string". Which reminds me of clojure spec or.
Should I extend the datahike schema spec with an additional :db/valueType? If yes, what is a sensible approach to that? Can the schema spec be modified via the datahike interface?
Or is it more sensible/idiomatic to for example split up the schema definition into multiples by defining :db/type/ref and then define one :db/ident per possible json-type with each having a concrete :db/valueType?
Thank you for reading my question!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing db/valueType schema and the Datahike interface, then compare the JSON Schema sum-type example with the available schema options. Done means deciding and documenting a sensible conversion approach, including whether the schema can be extended through the interface.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100