ruph
ruph

Reputation: 43

How to create tailable cursor in MongoDB shell?

I would like to create an endless processing loop for capped collection directly in MongoDB, but I can't find how I can get tailabale cursor in MongoDB shell. It's possible in Python with tailable option in Collection.find() though..

Upvotes: 4

Views: 3498

Answers (1)

Scott Hernandez
Scott Hernandez

Reputation: 7590

You can add the option after find() using addOption():

db.coll.find().addOption(2) // probably want to use 2(tailable) + 32(await_data)

See all the options here: http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol#MongoWireProtocol-OPQUERY

You will want to put this in a loop as even tailable cursors (w/await_data) return no results sometimes.

Upvotes: 7

Related Questions