Skip to content

Commit

Permalink
fix(document): make Document class an event emitter to support defini…
Browse files Browse the repository at this point in the history
…ng documents without models in node

Fix #8272
  • Loading branch information
vkarpov15 committed Nov 2, 2019
1 parent 374246d commit b86749e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/document.js
Expand Up @@ -184,6 +184,10 @@ utils.each(

Document.prototype.constructor = Document;

for (const i in EventEmitter.prototype) {
Document[i] = EventEmitter.prototype[i];
}

/**
* The documents schema.
*
Expand Down
2 changes: 2 additions & 0 deletions test/document.test.js
Expand Up @@ -136,6 +136,8 @@ describe('document', function() {
assert.ok(!myUserDoc.name);
myUserDoc.name = 123;
assert.strictEqual(myUserDoc.name, '123');

assert.ifError(myUserDoc.validateSync());
});
});

Expand Down

0 comments on commit b86749e

Please sign in to comment.