I have used the mongoose-field-encryption package which allows me to encrypt and decrypt the data before storing and accessing it. But I need to implement search functionality for the encrypted fields directly in the query itself.
The fields are email id, name, mobile number, address, etc.
You can use aggregate query's
$functionfeature to decrypt data within the query and apply filters. Explore$functionhere. Something likewhat it does is, create a new field named
decryptedEmailand the value of it is being computed by a decrypt function, and then we are filtering out the email we want