New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for $jsonSchema for mongodb #8135
Comments
IMO this is a crucial feature for Prisma+Mongo combination. |
What could a workflow for using |
@janpio I think it could work as a generator, in a manner similar to this: https://www.npmjs.com/package/prisma-json-schema-generator |
Btw I'm currently experimenting with that package, trying to see how much work it would be to convert its format into what $jsonSchema would take. |
"applying to Mongo models" sounds a bit like a Migration, similar to how we add indexes and uniques to MongoDB collections via We have little experience with $jsonSchema, so really are happy about any input on how it is used. I think we understand that one can apply it to a colleciton and then new data is validated against that schema. But what about existing data when a json schema is added the first time? What about changes to the schema after data was created? |
It would still be malformed. BUT, Mongo Atlas has some nice tooling to validate and fix existing data.
Same. |
So I've forked prisma-json-schema-generator and:
https://github.com/joindeed/prisma-mongo-json-schema-generator Feel free to experiment with it. |
Problem
Prisma currently does not support a mongodb json schema, is there any plan to add support to it?
Suggested solution
Having $jsonSchema support would be nice to have safe guarantees over the integrity of our data (when using an external tool, or performing raw aggregation operations, etc.).
It would also enable existing databases migration that rely on this feature (currently my case).
Finally it could also enable easy introspection of an existing database and help on other subjects as well, if it makes things simpler/safer, I think it could make sense to have it enabled by default and drop support for schema-less mongodb databases.
Additional context
One major pain point when dealing with jsonSchema was the lack of proper error reporting when an operation fails, would not impact end user that much thanks to the type-safety but would have been harder to develop / test, it has been fixed in SERVER-20547 that landed in
4.9.0
.The text was updated successfully, but these errors were encountered: