-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.0.27
-
Component/s: None
-
Environment:os: Windows 8, node: 0.12.2
-
Empty show more show less
In 1.x.x I used:
var collection = db.collection('socket');
var tailableRetryInterval = 200;
var errorTimeout = 1000;
function init(latest) {
return collection.find({_id: {$gt: latest._id}},
);
}
collection.isCapped(function(err, capped) {
if (err) throw err;
if (!capped) throw new Error('Collection ' + collection.collectionName + ' is not capped');
var latest = collection.find({}).sort(
).limit(1);
latest.nextObject(function(err, item) {
if (err) throw err;
if (!item) throw new Error('Collection ' + collection.collectionName + ' is empty');
(function listen(cursor) {
console.log('Adapter started tailing collection ' + collection.collectionName);
(function next(last) {
cursor.nextObject(function(err, item) {
if (err || !item)
console.log('item:', item);
next(item);
});
})(item);
})(init(item));
});
});
Everything was fine.
Now I'm trying:
function init(latest) {
return collection.find({_id: {$gt: latest._id}},
);
}
And get MongoError: No more documents in tailed cursor
Is it ok to skip this error or I'm doing something wrong?