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

Non-Array Children Values Not Decryped After Save #97

Open
dereekb opened this issue Feb 9, 2021 · 1 comment
Open

Non-Array Children Values Not Decryped After Save #97

dereekb opened this issue Feb 9, 2021 · 1 comment

Comments

@dereekb
Copy link

dereekb commented Feb 9, 2021

I ran into an issue where the children documents were not being recognized and decrypted properly. The children are not in an array, and just a single sub-document.

I'm using Typegoose and Mongoose:

"@typegoose/typegoose": "7.4.2",
"mongoose": "5.10.4",
"mongoose-encryption": "^2.0.3",

I made sure to add the encryptedChildren plugin, but noticed that both of the children documents were not being decrypted after saving. All other functions of the plugin are working great however, and the children are being decrypted properly when the models are loaded.

Digging into it, I noticed that the decryptEmbeddedDocs() function was only responding to nested documents if the value for that path was an array at time of decryption.

if (nestedDoc && nestedDoc[0] && isEmbeddedDocument(nestedDoc[0])) {

It looks like in your tests the children value is an array, and that's what is being tested against.

@joegoldbeck
Copy link
Owner

Ah, I wasn't aware of this use case of child documents! Probably makes sense to add support – happy to review any tested PRs.

https://stackoverflow.com/questions/23627976/mongoose-how-to-insert-a-single-subdocument-not-an-array/24724032

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