Skip to content

Commit 446d752

Browse files
makn3tizaNathaniel Dsouza
andauthored
Cursor.Observe() 'removed' event are not firing (#38)
* Cursor.Observe() 'removed' event are not firing I found that the 'removed' event in Cursor.Observe() are not firing, I guess its because `Data.db[collection].findOne({$and:[{_id:newDocument._id}, cursor._selector]})` returns null for deleted documents, maybe you can find a better solution than mine, thank you. * Update Collection.js Co-authored-by: Nathaniel Dsouza <[email protected]>
1 parent d746265 commit 446d752

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Collection.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ export const runObservers = (type, collection, newDocument, oldDocument) => {
1313
if(observers[collection]) {
1414
observers[collection].forEach(({cursor, callbacks}) => {
1515
if(callbacks[type]) {
16-
if(Data.db[collection].findOne({$and:[{_id:newDocument._id}, cursor._selector]})) {
16+
if(type === 'removed') {
17+
callbacks['removed'](newDocument);
18+
}
19+
else if(Data.db[collection].findOne({$and:[{_id:newDocument._id}, cursor._selector]})) {
1720
try {
1821
callbacks[type](newDocument, oldDocument);
1922
}

0 commit comments

Comments
 (0)