Add support for $jsonSchema for mongodb
See original GitHub issueProblem
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
.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:11
- Comments:7 (2 by maintainers)
Top GitHub Comments
IMO this is a crucial feature for Prisma+Mongo combination. Currently it’s very easy to run into runtime validation failures (even on read!) due to invalid data in the database. The problem comes from the fact that relational databases make it technically impossible to have invalid data not conforming to the schema in the database, and with Mongo we have no such guarantees unless we use $jsonSchema, which makes things super fragile. We’ve been running into terrible crashes in production, where in staging it all worked fine and then due to some slightly incorrect record everything blew up.
So I’ve forked prisma-json-schema-generator and:
https://github.com/joindeed/prisma-mongo-json-schema-generator
Feel free to experiment with it.