5 ms·
Are there any key/value JSON databases that enforce JSON Schema (or some other schema language)? That seems way better to me in situations where you actually ca
by seagreen 10y ago
Are there any key/value JSON databases that enforce JSON Schema (or some other schema language)? That seems way better to me in situations where you actually care about data integrity.
- mixedCase 10y agoThat'd just be Postgres. When you need an schema you use a normal table, when you need arbitrary JSON data you use a JSON schema.
- seagreen 10y agoI don't think so -- I'm looking for a database that will actually enforce a JSON schema for you -- I don't think Postgres has any built-in support for JSON schematization. I could always do validation before inserting data, but that opens me up to error on my side which I'd like to avoid=)
- mixedCase 10y agoYou are trying to hammer a screw in. If what you want is a facility for the database to provide you with JSON on query, Postgres has a couple of functions for that, namely array_to_json and row_to_json: https://www.postgresql.org/docs/9.2/static/functions-json.html https://www.postgresql.org/docs/9.2/static/functions-json.ht...
- seagreen 10y agoI just want a key/value JSON database with schematization. If that's "trying to hammer a screw" then so be it.
- mixedCase 10y agoMay I ask why would you insist on such a thing? Is it about avoiding SQL?
- seagreen 10y agoI'd like access to JSON Schema's impressive tooling. I haven't seen anything like this for SQL schemas: http://jeremydorn.com/json-editor/ http://jeremydorn.com/json-editor/ (Though if it exists please tell me, I'd be very interested!)
- 0XAFFE 10y agoDon't know for Web-Applications, but for Windows Applications there are tons of framework, which will create GUIs for you, given your Model. One very good, which I extensively used in my previous position was DevExpress (https://www.devexpress.com/Products/NET/Controls/WPF/Editors/ https://www.devexpress.com/Products/NET/Controls/WPF/Editors...).
- PeCaN 10y ago> I don't think Postgres has any built-in support for JSON schematization. Guess again. You can use JSON functions¹ in constraints: create table foo ( bar jsonb, constraint bar_count_is_positive check (bar->>'count' is not null and (bar->>'count')::integer >= 0) ); etc You could probably write a tool pretty easily to convert a JSON schema to Postgres constraints. 1. https://www.postgresql.org/docs/current/static/functions-json.html https://www.postgresql.org/docs/current/static/functions-jso...
- seagreen 10y agoSlick, thanks!
- kstirman 10y agoSee the docs for document validation, available in 3.2 and later. https://docs.mongodb.com/manual/core/document-validation/ https://docs.mongodb.com/manual/core/document-validation/
- seagreen 10y agoAwesome, I had no idea they'd added that!
- findjashua 10y agoAny particular reason you want it at the db layer? Wouldn't having it at the query builder/orm layer suffice?
- seagreen 10y agoI think it would be useful in various situations. In my particular case clients of different quality are connecting to a local datastore. I'd like to make sure that even if they mess up validation the data in the store still matches the schemas it claims to. Of course, I could have them connect to a local process instead and have that process handle validation before the data goes in the store, but it's always nice to avoid intermediaries.
- prodigal_erik 10y agoIf your data store has existed for more than a year or two, it's very likely that other people in the org have written utilities against it (in different languages) that you personally are unaware of. You can reliably and atomically change the data store's business logic but not all the clients'.
- rakoo 10y agoA little late to reply, but CouchDB has Validate Doc Update functions that can validate based on the old document, the new document, and the user context, in javascript: http://docs.couchdb.org/en/1.6.1/couchapp/ddocs.html#validate-document-update-functions http://docs.couchdb.org/en/1.6.1/couchapp/ddocs.html#validat...