-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Remove all reserved keywords from schema #9010
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
Comments
Good suggestions @AbdelrahmanHafez , I agree with the However, I think we should still expose The tradeoff is that this will make life more difficult for plugin authors. If you allow |
Yep, that's what I am proposing. // we should be using that internally
Document.prototype[validateSymbol] = function validate(){};
// exposed to users, if overwritten they should use symbols to access the method
Document.prototype.validate = Document.prototype[validateSymbol]; Users will have access to methods via properties, and if they try to add a path that overwrites the method, we show a warning (that can be suppressed), telling them that if you use that field, you'll overwrite a method, and you'll need to use symbols to access those methods, and refer to a section that explains this further in the docs.
If users use |
That's fair. We would have to come up with a list of symbols to export though. Another alternative would be to encourage plugin authors to use |
@AbdelrahmanHafez do you have some time to take a look at this? Would be very helpful. The only change I'd suggest would be to use |
I think this is part of the same issue, which has been addressed for other cases such as the option
I can workaround this problem by renaming I'm getting the Typescript error |
@ErnestoBorio can you please open a new issue and follow the issue template? Your issue is unrelated. |
Allow usage of schema reserved keywords
re #8940 (comment) #8940 (comment)
It would be great if we could get rid of entirely of schema reserved keywords.
It's a bit tricky, but I believe it's doable. AFAIK the reason we're having reserved keywords is that we don't want to overwrite document methods.
Even for those, we could allow them and offer alternatives to users, and use that alternative internally. Symbols seem like a good option for internal implementation.
This could be quite useful for people migrating from other types of DBs to MongoDB without having to change their fields' names and don't want their apps to break other apps that depend on their data being the same names.
Thoughts? @vkarpov15 @lineus
The text was updated successfully, but these errors were encountered: