-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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.$__schema.paths[p].splitPath is not a function" when defining a document array using a schema from an earlier version of Mongoose #10453
Comments
Check that you do not have multiple versions of mongoose installed |
Hey @IslandRhythms . example:
|
@lucaslimao this does look indicative of having multiple versions of Mongoose installed. My best guess is that Can you please try running |
Hello :)
I'm using schemas defined in a different repository, both repositories have Mongoose 6.1.2 After some tests with Mongoose, I figured out that I can solve the problem by removing this I don't have any other error. I would be interested to have your thoughts about this case.
Thanks ! |
@gregorybellencontre can you please paste the output of |
@vkarpov15 Here's the result of the
|
So you do have 2 copies of Mongoose after all, they're just the same version. Where does the nested version of mongoose come from? |
Indeed, I'm using a personal NPM package where I store some Mongoose schemas. |
If you have an npm package that stores Mongoose schemas, we'd recommend listing Mongoose in |
I am facing the same issue but only when using the 'remote' schema in an Array. I defined a
When trying to use this schema in my main repo like this:
I am getting an error:
When using it as a single item, it works fine:
Output of
Output of
In |
I get this issue after updating from
Edit: const newDoc = new Model({
_id: mongoose.Types.ObjectId('customid'),
});
const insertedDoc = await newDoc.save(); |
We'll try a different approach with 50b670c. Our approach of throwing an error if you pass something that isn't strictly As a workaround, you can always wrap your shared schema in a
This should work, even if |
…ent version of Mongoose module Re: #10453
On second thought, we're just going to improve the error message to suggest using |
Do you want to request a feature or report a bug?
Yes.
What is the current behavior?
I updated the lib version recently.
from 5.9.4 to 5.13.2
After updated I run the code, I get the following error: this.$__schema.paths[p].splitPath is not a function started.
If the current behavior is a bug, please provide the steps to reproduce.
code snippet
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node.js 12.18.3
Mongoose 5.13.2
Mongo 4.4
The text was updated successfully, but these errors were encountered: