[DOCS-674] Tailiable Cursors Page Created: 25/Oct/12  Updated: 13/Nov/23  Resolved: 20/Dec/12

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: v1.0, Server_Docs_20231030, Server_Docs_20231106, Server_Docs_20231105, Server_Docs_20231113

Type: Task Priority: Major - P3
Reporter: Sam Kleinman (Inactive) Assignee: Kay Kim (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 11 years, 8 weeks, 5 days ago

 Description   

http://www.mongodb.org/display/DOCS/Tailable+Cursors

This should probably be a new page. Probably a tutorial and a page in core/applications.



 Comments   
Comment by auto [ 22/Dec/12 ]

Author:

{u'date': u'2012-12-20T19:36:00Z', u'email': u'kay.kim@10gen.com', u'name': u'kay'}

Message: DOCS-674 tailable cursor final edit after scott - removing javascript example
Branch: master
https://github.com/mongodb/docs/commit/9e8de2751d8a202d5d5fc496ee0f4aecd8f2ce8d

Comment by auto [ 22/Dec/12 ]

Author:

{u'date': u'2012-12-20T18:59:47Z', u'name': u'kay', u'email': u'kay.kim@10gen.com'}

Message: DOCS-674 tailable cursor final edit after scott and tyler
Branch: master
https://github.com/mongodb/docs/commit/f39cd3977983c1bf0a7b18c5ac52a2ed01070c30

Comment by auto [ 22/Dec/12 ]

Author:

{u'date': u'2012-12-14T05:39:58Z', u'name': u'kay', u'email': u'kay.kim@10gen.com'}

Message: DOCS-674 tailable cursor incorporate ed and scott's comments
Branch: master
https://github.com/mongodb/docs/commit/5b06203f47874d169cd7fc64ee211494e4621193

Comment by auto [ 22/Dec/12 ]

Author:

{u'date': u'2012-12-14T04:28:14Z', u'name': u'kay', u'email': u'kay.kim@10gen.com'}

Message: DOCS-674 tailable cursor incorporate ed and scott's comments
Branch: master
https://github.com/mongodb/docs/commit/b0f1826737dab89ca53e14c273aa0533a6df145a

Comment by auto [ 22/Dec/12 ]

Author:

{u'date': u'2012-12-07T17:20:21Z', u'name': u'kay', u'email': u'kay.kim@10gen.com'}

Message: DOCS-674 migrate tailable cursor page
Branch: master
https://github.com/mongodb/docs/commit/7567b9a7d4ceef3e6f7361a2d3099e2a54d11625

Comment by Kay Kim (Inactive) [ 20/Dec/12 ]

Removed the javascript example per Scott's okay

This example spawns gazillions of cursors – can check via db.runCommand(

{ cursorInfo: 1 }

)

var coll = db.myCappedCollection;

var startDoc = coll.find().hint(

{ '$natural': 1 }

).limit(1).next();
var lastValue = startDoc['insertDate'];
printjson(startDoc)

while (1) {

var cursor = coll.find( { 'insertDate' :

{ '$gt' : lastValue }

} ).hint(

{ '$natural': 1 }

).addOption( DBQuery.Option.tailable ).addOption( DBQuery.Option.awaitData );

while ( cursor.hasNext() )

{ var doc = cursor.next(); lastValue = doc['insertDate']; printjson(doc); }

}


This example works but we can't handle a dead cursor

var coll = db.myCappedCollection;

var startDoc = coll.find().hint(

{ '$natural': 1 }

).limit(1).next();
var lastValue = startDoc['insertDate'];
printjson(startDoc)

var cursor = coll.find( { 'insertDate' :

{ '$gt' : lastValue }

}
).hint(

{ '$natural': 1 }

).addOption( DBQuery.Option.tailable ).addOption( DBQuery.Option.awaitData );

while (1) {
try {
if ( cursor.hasNext() )

{ var doc = cursor.next(); lastValue = doc['insertDate']; printjson(doc); }

} catch (e)

{ break; }

}

Generated at Thu Feb 08 07:39:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.