Storing CUE in postgres JSON field #1250
Replies: 2 comments 3 replies
-
Sounds like a custom (en/de)coder for a format between JSON and JSONSchema? How much of the CUE language are you exposing to the contract authors? Imports, disjunctions, and comprehensions? These are tricker parts of the language to handle in Go. Are there any constraints you can put on the problem space? For the definition conversion, how would your conversion handle |
Beta Was this translation helpful? Give feedback.
-
Making a jsonschema generator wouldn't be terribly difficult and mostly entails refactoring the OpenAPI generator to pull out that functionality and deal with the slight differences between the two. |
Beta Was this translation helpful? Give feedback.
-
Hi CUE's
At balena.io we want to adopt CUE for an internal document format. Can I please get your thoughts on this rabbit hole?
Internally, we use documents know as contracts, and they contain a mix of JSON and JSONSchema. Plain JSON for concrete values and JSONSchema for abstract values. The contracts are used in many repos, you can think of them as a sort of manifest. The contracts are also stored and queried in PostgreSQL, as
jsonb
fields.We would like to use CUE as the contract file representation. JSONSchema is very verbose and large documents become very hard to read and manipulate, CUE is much more concise and would improve the UX when working with contracts.
However, if we use CUE we need a way to store the document in postgres. The most obvious solution would be to use CUE to JSONSchema. However, this appears incomplete at the moment, and we would also need support for importing back to CUE and support for mixed mode data and schema objects.
Since we only need to query on the data, not the schema; we are considering a simplified JSON representation where schema is stored as a CUE string.
Given the following CUE:
Convert to the following JSON:
I'm planning to implement a custom (en/de)coder.
I am asking as sort of sanity check, does this sound like a reasonable solution for the given problem?
Beta Was this translation helpful? Give feedback.
All reactions