Skip to content

Commit b86749e

Browse files
committed
fix(document): make Document class an event emitter to support defining documents without models in node
Fix #8272
1 parent 374246d commit b86749e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/document.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ utils.each(
184184

185185
Document.prototype.constructor = Document;
186186

187+
for (const i in EventEmitter.prototype) {
188+
Document[i] = EventEmitter.prototype[i];
189+
}
190+
187191
/**
188192
* The documents schema.
189193
*

test/document.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ describe('document', function() {
136136
assert.ok(!myUserDoc.name);
137137
myUserDoc.name = 123;
138138
assert.strictEqual(myUserDoc.name, '123');
139+
140+
assert.ifError(myUserDoc.validateSync());
139141
});
140142
});
141143

0 commit comments

Comments
 (0)