-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
NestJS PrismaService and Extending it With Encryption #78
Comments
Your issue is with the extension mechanism. NestJS uses a class that inherits from the PrismaClient, but applying extensions require to use the return value of There are issues on the Prisma repo about how to deal with Nest and extensions, you should be able to find a solution there. |
Thanks for your reply @franky47, prisma/prisma#20833 |
@franky47 Btw, do you have a quick workaround? Or can you point me more directly to issues that have some quick solutions? |
Thank you sir! |
@franky47 Sir, would it be better practice to have two PrismaService, one specifically for creating records for tables with encrypted column(s) and another for general database operations? I see the link that you shared requires me to purposefully inject the CustomPrismaService whenever I need it.
|
That sounds like a recipe for disaster, as a lot can go wrong: overwriting encrypted records with clear-text values (leaking data), or sending ciphertext to the front-end. The extension makes operations transparent, so inject it to configure your client and you can forget about it being here (albeit losing some features like partial search and sorting on encrypted fields). |
@franky47 Thank you for your reply, oh, I am just trying to encrypt one or two columns of some of my tables, I am not sure how I can actually 'inject it to configure your client', is the example in the documentation sufficient? I read it. |
I am trying to encrypt a particular field in my Prisma model.
Here is the full codes of my
PrismaService
residing my in NestJS'sPrismaModule
:On my
prisma.schema
:Within my database, after using
prismaService.user.create
, the resulting entry in the PostgreSQL database is NOT encrypted.Any idea how does it work? Thank you.
The text was updated successfully, but these errors were encountered: