-
Notifications
You must be signed in to change notification settings - Fork 27
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
this.$__path is not a function error when using with Mongoose #43
Comments
can you please add a full stack trace? |
|
I realize now this doesn't happen with just ANY mongoose document, I'll try to narrow down what the culprits could be. |
Ok, I was able to figure out how to reproduce the issue. Here's the code:
And here are the logs:
It's funny though, if we also set option
|
So, the problem seems to be when mongoose tries to get the "id" virtual of a subdocument. Declaring this schema, which is equivalent to the one above, will also work as it will make the subdocument NOT have an _id field (and, consequently, not an "id" virtual). Sorry, should I be bringing this issue to mongoose instead? It seems to be very specific.
|
It seems the decycling breaks the mongoose @filetvignon would you be so kind and check if https://github.com/BridgeAR/safe-stable-stringify works for you? I guess that might work as the decycling works different. |
Hey @BridgeAR, I have checked it and it does work! =] |
@filetvignon great! It is out there for quite some time and it should be very stable. I would actually call it safer to use since it has less special handling than this implementation. |
Do we have any update on this ? Other than using a fork |
I think this would need a a volunteer to write a PR to fix it - we are not mongoose users, and it's not really a priority for us atm. |
Whenever I try to use fast-safe-stringify with a Mongoose Object, I get the error "this.$__path is not a function". I tried investigating exactly what is it in mongoose documents that cause this but couldn't find anything.
JSON.stringify() works with mongoose objects just fine.
I'm using the newest version of both packages:
fast-safe-stringify: 2.0.6,
mongoose: 8.6.8,
node: 10.16.1
The text was updated successfully, but these errors were encountered: