-
-
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
Any schema with a domain
attribute fails to save.
#1338
Comments
Just curious, What happens if you do this? var BorkSchema = new Schema({
userId: { type: Schema.ObjectId, required: true }
, domain: String
, _events: String
, emit: String
, addListener: String
, on: String
, removeAllListeners: String
, removeListener: String
, once: String
, _maxListeners: String
, listeners: String
}); |
It would fail, of course. That's not debated. Inheriting EventEmitter is, and will continue, happening, so expectations need to be made clear with regards to how to extend it while minimizing the possibility of future breakage. Clearly, everyone understands that overriding What happened is that Node core introduced a Given how widespread inheriting from |
this has come up before and Isaac makes a great case. we could either
At this time, option 1 seems like the best choice. In 4x I want to revisit the document model and explore getting rid of methods like save etc and pushing that logic onto the Model where it belongs. Would also allow not inheriting from EE. |
Can you not just put Document keys on a different data object? Or do you depend on being able to do |
Side note: prefixing ObjectId properties with an underscore is very common, similar to _id. |
Hey Isaac, thanks for exploring this issue. Yes, we have getters/setters on the document itself which push data to the internal We take security very seriously. If you have any more observations we'd love to hear more / discuss further. |
throw friendly errors when `emit` or `_events` are used in schema. closes #1338
throw friendly errors when `emit` or `_events` are used in schema. #1338
This is still an issue: Any document with a |
nice |
Can we make a note of these in the docs as well? |
Boo. |
Not an issue in 4.0 anymore, since Document no longer inherits from EventEmitter to avoid this particular mess. See #1451. As a side note, I really hope ES7 provides better control over encapsulation and domains go away before Node 1.0. |
If I define a Schema with a
domain
property, and then attempt to save a model instance, it fails with the following error:In this case, "github.com" is the value I assigned to the
domain
property with a schema that looks like:Note, this is actually a conflict with Node core, which has a colliding
domain
property with anything that inherits fromEventEmitter
. I have a running discussion with @isaacs about it here:nodejs/node-v0.x-archive#3922
It may help to get more input from Mongoose developers.
The text was updated successfully, but these errors were encountered: