mongoosejs / mongoose-lean-virtuals

Attach virtuals to the results of mongoose lean() queries
Apache License 2.0
45 stars 24 forks source link

Fix explicit virtuals for subdocuments (#34) #35

Closed ChrisLahaye closed 4 years ago

ChrisLahaye commented 4 years ago

Signed-off-by: Chris Lahaye dev@chrislahaye.com

ChrisLahaye commented 4 years ago

@vkarpov15 I add some tests.

The first test case, without my change it attempts to apply the virtual lowercaseName in any nested array subschema, even though the virtual is only present in the root schema.

The second test case, without my change it attempts to apply the virtual childs.uppercaseOther in the root schema, even though the virtual is only present in the schema of childs.

The third test case is a combination of the first two.

ChrisLahaye commented 4 years ago

Rebased on master