question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature: expose dmmf information on Prisma client

See original GitHub issue

Problem

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:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
janpiocommented, May 7, 2021

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.

0reactions
janpiocommented, May 7, 2021

I think I invited you to a channel, if that was not you please ping me @janpio

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expose native types mapping to DMMF · Issue #6844 - GitHub
Problem We have model with defined native type model Post { id Int @id title String @db.VarChar(200) } Custom generators may want to...
Read more >
What's new in Prisma? (Q2/2022)
Learn about everything that has happened in the Prisma ecosystem and community from April to July 2022.
Read more >
Prisma Client API (Reference)
From version 4.5.0, this type exposes all fields on the model. This means that when you filter for a single record based on...
Read more >
Preview features (Reference) - Prisma
For information about available preview features and how to enable them, see: Prisma Client and Prisma schema preview features · Prisma CLI preview...
Read more >
Operating against partial structures of your model types - Prisma
A cleaner solution to this is to use the UserGetPayload type that is generated and exposed by Prisma Client under the Prisma namespace...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found