-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
'set' can no longer be used in a schema? #1939
Comments
+1 |
Would love to change this but it will be horribly backwards breaking. |
Hi @vkarpov15 Any plans when There is an option |
OK, providing option is impossible, I guess. Can you advice anything? |
We don't have any concrete timeline for 5.0 just yet. Will look into adding an option to support this for next minor release. |
After upgrading to Mongoose 3.8.8 from 3.8.5 we were surprised to find that our server began crashing with the following message:
To be clear our schema defines a property called "set" (which is the ID of the set that a particular item belongs to). This has been used in our MongoDB documents for a long time. There was nothing wrong with having having a document property called "set" in 3.8.5, and it is a valid MongoDB document property.
I'm not sure what changed within Mongoose that is causing Mongoose to reject it now (perhaps it thinks it will collide with the "$set" MongoDB command?) I consider this to a bug, and it will prevent me from upgrading to the latest Mongoose it is fixed. I'll check into the Mongoose code to see if I find anything obviously wrong.
Edit: So I checked into the Mongoose code and it looks like Mongoose is rejecting the "set" property because it would override one of Mongoose' methods. I understand the reason for this, but I consider this to be indicative of a fundamentally flawed object architecture in Mongoose.
Document level properties should not be living at the same level as Mongoose's methods, and if there is a collision between the two I consider that to be an issue with the Mongoose object model. Users of Mongoose should never be forced to avoid certain property names which are valid MongoDB property names simply because Mongoose wants to use them for methods.
The text was updated successfully, but these errors were encountered: