-
Notifications
You must be signed in to change notification settings - Fork 24
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
No support for .parent() or .ownerDocument()? #40
Comments
The lack of I think the way to go is for us to add a |
Something like that would work here - as long as I can get some kind of context to call .parent and/or .ownerDocument for a given document.
… On Oct 4, 2020, at 1:38 PM, Valeri Karpov ***@***.***> wrote:
The lack of .parent() is intentional. With lean, you get a raw POJO rather than a Mongoose document, so naturally it won't have a parent() function.
I think the way to go is for us to add a parent() function to the mongoose-lean-virtuals plugin, like require('mongoose-lean-virtuals').parent(myObj), that allows you to get the parent. What do you think @jnardone ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We have a virtual on a child schema that needs visibility to the parent document.
I was hoping (expecting?) that the ability to see .parent() (or .ownerDocument()) from Mongoose would work here as documented in other places e.g. https://mongoosejs.com/docs/subdocs.html#subdoc-parents
But these are undefined. Should they be? Is there a way of accessing the parent document as part of leanvirtuals?
Stack trace that happens:
(the error occurs on the line where I attempt to call
.parent()
or.ownerDocument()
)How do I reference the parent document from a child virtual when using this library?
Mongoose ver 5.10.2
Mongoose-lean-virtuals ver 0.6.9
The text was updated successfully, but these errors were encountered: