47ng / prisma-field-encryption

Transparent field-level encryption at rest for Prisma
https://github.com/franky47/prisma-field-encryption-sandbox
MIT License
223 stars 27 forks source link

Filtering secured field with mode-insensitive #108

Open SerGem811 opened 3 weeks ago

SerGem811 commented 3 weeks ago

Hi, thanks for your effort to provide useful library, i like it. I can see that filtering is not supporting for contains, startWith, endWith. But is there anyway to make it working for mode-insensitive?

I am using equals with insensitive mode, but it is also not working, so i'd love to hear your suggestion for it.

Regard

franky47 commented 3 weeks ago

Hi,

Unfortunately no, any kind of partial match (whether in parts of the string or case insensitivity) cannot be supported.

One possibility here though would be to store a separate field, which contains a lowercase copy of the original, and on which you apply a hash for exact matching. Upon querying, you'd lowercase the query and perform an exact match.