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

mongooseFieldEncryption - field level encryption does not work when replaceOne is used #87

Open
SnehaReddy2573 opened this issue Feb 15, 2023 · 1 comment
Assignees

Comments

@SnehaReddy2573
Copy link

We have added mongooseFieldEncryption plugin to our schema which is encrypting the relevant fields as expected when save is used. But the problem is with the replaceOne function. 

To update an existing document in mongoose collection, we use replaceOne. When replaceOne is used, the field which was already encrypted in the document is replaced with an actual field value (i.e. the field stays unencrypted). 

In the documentation of mongoose-field-encryption, there is no information w.r.t replaceOne. Could you give us some insights regarding this?

@wheresvic
Copy link
Owner

Hi @SnehaReddy2573

At the moment replaceOne functionality has not been implemented. I can look into this but cannot guarantee when it will be done. In the meantime, can you maybe just do a delete and insert a new document? Or rather insert a new one first and delete the old one or just do findOneAndUpdate which is supported.

There are a bunch of tests which you can use as a reference point for all available functionality:

it("should encrypt string fields on fineOneAndUpdate", function () {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants