Skip to content

Commit

Permalink
fixed; add EventEmitter props to reserved paths
Browse files Browse the repository at this point in the history
throw friendly errors when `emit` or `_events` are used in schema.

#1338
  • Loading branch information
aheckmann committed Feb 14, 2013
1 parent 61ae79b commit b1fba22
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ Schema.prototype.add = function add (obj, prefix) {
*
* Keys in this object are names that are rejected in schema declarations b/c they conflict with mongoose functionality. Using these key name will throw an error.
*
* on, db, init, isNew, errors, schema, options, modelName, collection
* on, emit, _events, db, init, isNew, errors, schema, options, modelName, collection, _pres, _posts
*
* _NOTE:_ Use of these terms as method names is permitted, but play at your own risk, as they may be existing mongoose document methods you are stomping on.
*
Expand All @@ -229,8 +229,10 @@ reserved.errors =
reserved.schema =
reserved.options =
reserved.modelName =
reserved._pres = reserved._posts = // hooks.js
reserved.collection = 1;
reserved.collection =
reserved.emit = // EventEmitter
reserved._events = // EventEmitter
reserved._pres = reserved._posts = 1 // hooks.js

/**
* Gets/sets schema paths.
Expand Down

0 comments on commit b1fba22

Please sign in to comment.