Skip to content
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

Only works for Model and not embedded Type? #74

Open
zmays opened this issue Aug 4, 2023 · 6 comments · May be fixed by #105
Open

Only works for Model and not embedded Type? #74

zmays opened this issue Aug 4, 2023 · 6 comments · May be fixed by #105

Comments

@zmays
Copy link

zmays commented Aug 4, 2023

using mongodb and so a lot of our encrypted fields are in embedded documents, which are done by Type instead of Model: https://www.prisma.io/docs/concepts/components/prisma-schema/data-model#defining-composite-types

I've added this lib, but only get encryption on fields defined in Models.

Supporting types on your roadmap? Want a pr for it?

@franky47
Copy link
Member

franky47 commented Aug 4, 2023

Sure, if you feel like going for a PR for this, go ahead!

This will probably require adjusting the DMMF parser to look for those Type definitions, and see how to connect that to the visitor system, which visits each node of a query to look for leaves to encrypt/decrypt, with the knowledge of what model it's currently looking at.

@zmays
Copy link
Author

zmays commented Aug 8, 2023

I'm running npm link to test some changes I made, but the require('@prisma/client').Prisma.dmmf in extensions.ts is returning undefined when I run it with my repo - ran into this before?

@franky47
Copy link
Member

franky47 commented Aug 8, 2023

This is usually a sign that you need to generate the Prisma client with prisma generate, to get the required DMMF.

FYI, if you want to explore the object structure more easily, you can use import { getDMMF } from '@prisma/internals', feed it the contents of your schema, and dump the result into a JSON file.

@zmays
Copy link
Author

zmays commented Aug 8, 2023

Thanks, it is definitely generated, I'm guessing it is trying to import from the package node_modules, instead of the source repo I linked the package to

@franky47
Copy link
Member

franky47 commented Aug 8, 2023

Yeah with npm link it may not work exactly as intended in a regular dependency install. Feel free to locally point the require to a correct relative path.

@zmays
Copy link
Author

zmays commented Aug 23, 2023

Hey sorry this has hit the backburner for me at the moment

@gurjotkaur20 gurjotkaur20 linked a pull request Mar 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants