Feature: expose dmmf information on Prisma client
See original GitHub issueProblem
I’m author of https://casl.js.org/ (permission management library) and working on integrating prisma with casl. This requires translation of MongoDB Query dialect into Prisma WhereInput. To do, so I’d like to overload some of the Mongo operators. For example, in Mongo $in
can be used for both arrays and scalars but in Prisma there are separate operators: in
for scalars and has
& co for arrays.
Suggested solution
By having access to prisma._dmmf.modelMap
I can implement this overload because I can check the field type and if it’s an array convery $in
to hasSome
and if it’s a scalar to in
Alternatives
I can use prisma._dmmf.modelMap
but it’s not reliable as it can go away in any next release. Alternative solution for me is to implement PrismaQuery interpreter in JavaScript, this is doable but requires more dancing with Prisma types. I will describe it in another issue.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Be aware that
Prisma.dmmf
is not a public, stable API so it is not uncommon for this to be changed with short or no notice.Are you using a Slack community regularly? Then we could create a shared channel with our community at slack.prisma.io for the cases where you have questions etc.
When you are done, please also let us know over at https://github.com/prisma/e2e-tests/ so we can create an end to end test. Those are tested with each of our development versions to catch regressions and mismatches early.
I think I invited you to a channel, if that was not you please ping me @janpio