Open
Description
I think this was introduced by #43
I have a subdocument that is transformed by the getter into a single object that should be assigned to the original document:
{
_id: false,
type: {
amount: {
type: mongoose.Types.Decimal128,
required: true,
},
currency: {
type: String,
required: true,
},
},
set: transformCurrencyToDbStructure,
get: transformCurrencyFromDbStructure,
}
This worked before on 2.0.1 but after updating to 2.2.1 it just returns the original subdocument without applying the getter.
mongoose-lean-getters/index.js
Line 121 in 9fcb880
Upon further investigation, it reaches this point and then tries to apply getters to the fields of the subdocument (passing along the transformed subdocument which is now a totally different structure) and then discards the transformed value (
val
) instead of assigning it to the document.
Locally I've patched it to do mpath.set(path, val, doc);
in this case too which has resolved it but I am not certain whether this may have undesired side effects. I can put up a PR for this.
Metadata
Metadata
Assignees
Labels
No labels