MongoDB Documentation, Release 3.0.4 Modifications to the Pattern Another approach is to add a version field to the documents. Applications increment this field upon each update operation to the documents. You must be able to ensure that all clients that connect to your database include the version field in the query predicate. To associate increasing numbers with documents in a collection, you can use one of the methods described in Create an Auto-Incrementing Sequence Field (page 125). For more approaches, see Concurrency Control (page 82). By default, MongoDB will automatically close a cursor when the client has exhausted all results in the cursor. How- ever, for capped collections (page 209) you may use a Tailable Cursor that remains open after the client exhausts the results in the initial cursor. Tailable cursors are conceptually equivalent to the tail Unix command with the -f option (i.e. with “follow” mode). After clients insert new additional documents into a capped collection, the tailable cursor will continue to retrieve documents. Use tailable cursors on capped collections that have high write volumes where indexes aren’t practical. For instance, MongoDB replication (page 559) uses tailable cursors to tail the primary’s oplog . Note: If your query is on an indexed field, do not use tailable cursors, but instead, use a regular cursor. Keep track of the last value of the indexed field returned by the query. To retrieve the newly added documents, query the collection again using the last value of the indexed field in the query criteria, as in the following example: Overview 3.3.11 Create Tailable Cursor ) if ( results.hasWriteError() ) { print( "unexpected error updating document: " + tojson(results) ); } else if ( results.nMatched === 0 ) { print( "No matching document for " + "{ _id: "+ myDocument._id.toString() + ", quantity: " + oldQuantity + ", reordered: " + oldReordered + " } " ); } } Consider the following behaviors related to tailable cursors: • Tailable cursors do not use indexes and return documents in natural order . • Because tailable cursors do not use indexes, the initial scan for the query may be expensive; but, after initially exhausting the cursor, subsequent retrievals of the newly added documents are inexpensive. • Tailable cursors may become dead , or invalid, if either: – the query returns no match. – the cursor returns the document at the “end” of the collection and then the application deletes that docu- ment. 3.3. MongoDB CRUD Tutorials 123 db.<collection>.find( { indexedField: { $gt: <lastvalue> } } )