How to always return the executed value of a getter?

@Stennie_X Thanks for the help! Maybe I can throw another example your way that involves using a setter AND getter:

Let’s say for privacy reasons instead of lower-casing the email we hash it and store its encrypted value. And when we read the value, we always want the decrypted value returned. So the User mongoose schema would have a email property like (where decrypt and encrypt are the respective encryption functions):

email: { type: String, get: decrypt, set: encrypt }

Is there a way to always return the decrypted value without first having to access the property directly or convering to JSON:

user.email
// or
res.send(user)

I would like all my DB queries on User to automatically return with the decrypted email value. Would a “find” middleware be appropriate for this? (sorry, just learning about middlewares)

schema.post('find', decryptMiddlewareFunc)