-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
Affects Version/s: 2.0.15
-
Component/s: None
-
Environment:OSX 10.10, IO.js 1.1, MongoDB Node Driver 2.0.15
-
None
-
None
-
None
-
None
-
None
-
None
-
None
I want to attach a listener to capped collection. Collection is not empty, it contains some data, but none of them matches the filter. When I run the code on 1.4.30, the stream start to listen correctly.
```javascript
var filter =
var options = {
tailable: true,
awaitdata: true,
sort: {$natural: 1}
}
var cursor = db.collection('mycoll').find(filter, options);
var stream = cursor.stream();
stream.on('end', function() {
// not triggered on 1.4.30
});
```
But when I run the code on 2.0.15, the stream is closed immediately.
```javascript
var filter =
var options = {
tailable: true,
awaitData: true,
sort: {$natural: 1}
}
var cursor = db.collection('mycoll').find(filter, options);
cursor.on('end', function() {
// this is called imediately on 2.0.15
});
```
When I change order to `{$natural: -1}`, it start to work correctly. It also works correctly, when there is at least one document in the collection matching the filter.