From 1021d2be36c104554a5fe8f391e6b0eec8a307f8 Mon Sep 17 00:00:00 2001 From: kay Date: Wed, 13 Feb 2013 11:53:53 -0500 Subject: [PATCH 1/4] DOCS-860 add the cursor.addOption method --- source/reference/method/cursor.addOption.txt | 28 ++++++++++++++++++++ source/tutorial/create-tailable-cursor.txt | 5 ++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 source/reference/method/cursor.addOption.txt diff --git a/source/reference/method/cursor.addOption.txt b/source/reference/method/cursor.addOption.txt new file mode 100644 index 00000000000..52190c92774 --- /dev/null +++ b/source/reference/method/cursor.addOption.txt @@ -0,0 +1,28 @@ +================== +cursor.addOption() +================== + +.. default-domain:: mongodb + +.. method:: cursor.addOption() + + Use the :method:`cursor.addOption()` method on a cursor to add + OP_QUERY wire protocol flags, such as the ``tailable`` flag. + + :param flag: OP_Query wire protocol flag. See :meta-driver:`MongoDB + wire protocol ` for more + information on MongoDB Wire Protocols and the OP_Query flags. + + For the :program:`mongo` shell, see the list of :ref:`cursor flags + ` available in the shell. For the driver-specific + list, see your :doc:`driver documentation `. + + The following example in the :program:`mongo` shell adds the + ``DBQuery.Option.tailable`` and ``DBQuery.Option.awaitData`` flags + to ensure the cursor returned from the query is a tailable cursor + that waits for a few seconds when the cursor reaches the end of the + data: + + .. code-block:: javascript + + var cursor = db.myCappedCollection.find().addOption( DBQuery.Option.tailable ).addOption( DBQuery.Option.awaitData ); diff --git a/source/tutorial/create-tailable-cursor.txt b/source/tutorial/create-tailable-cursor.txt index 43c7d8a8d82..3c0482c4e16 100644 --- a/source/tutorial/create-tailable-cursor.txt +++ b/source/tutorial/create-tailable-cursor.txt @@ -54,9 +54,10 @@ Consider the following behaviors related to tailable cursors: A *dead* cursor has an id of ``0``. See your :doc:`driver documentation ` for the -driver-specific method to specify the tailable cursor. For more +driver-specific method to specify the tailable cursor. For more information on the details of specifying a tailable cursor, see -:meta-driver:`Mongo wire protocol ` documentation. +:meta-driver:`MongoDB wire protocol ` +documentation. C++ Example ----------- From 24a158929158b3cd97879719b08f517dc66531b7 Mon Sep 17 00:00:00 2001 From: kay Date: Wed, 13 Feb 2013 13:37:00 -0500 Subject: [PATCH 2/4] DOCS-860 addOption method, includes warning --- source/reference/method/cursor.addOption.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/reference/method/cursor.addOption.txt b/source/reference/method/cursor.addOption.txt index 52190c92774..231734bb867 100644 --- a/source/reference/method/cursor.addOption.txt +++ b/source/reference/method/cursor.addOption.txt @@ -26,3 +26,7 @@ cursor.addOption() .. code-block:: javascript var cursor = db.myCappedCollection.find().addOption( DBQuery.Option.tailable ).addOption( DBQuery.Option.awaitData ); + + .. warning:: Adding incorrect wire protocol flags can cause problems + and/or extra server load. + \ No newline at end of file From 9708faac0eee972916f2de0a4e3b61a0167f42e4 Mon Sep 17 00:00:00 2001 From: kay Date: Wed, 13 Feb 2013 18:16:52 -0500 Subject: [PATCH 3/4] DOCS-860 cursor.addOption --- source/reference/method/cursor.addOption.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/reference/method/cursor.addOption.txt b/source/reference/method/cursor.addOption.txt index 231734bb867..2626028bc76 100644 --- a/source/reference/method/cursor.addOption.txt +++ b/source/reference/method/cursor.addOption.txt @@ -9,9 +9,10 @@ cursor.addOption() Use the :method:`cursor.addOption()` method on a cursor to add OP_QUERY wire protocol flags, such as the ``tailable`` flag. - :param flag: OP_Query wire protocol flag. See :meta-driver:`MongoDB - wire protocol ` for more - information on MongoDB Wire Protocols and the OP_Query flags. + :param flag: OP_QUERY wire protocol flag. See :meta-driver:`MongoDB + wire protocol ` for more + information on MongoDB Wire Protocols and the OP_QUERY + flags. For the :program:`mongo` shell, see the list of :ref:`cursor flags ` available in the shell. For the driver-specific @@ -25,7 +26,8 @@ cursor.addOption() .. code-block:: javascript - var cursor = db.myCappedCollection.find().addOption( DBQuery.Option.tailable ).addOption( DBQuery.Option.awaitData ); + var cursor = db.myCappedCollection.find().addOption(DBQuery.Option.tailable). + addOption(DBQuery.Option.awaitData); .. warning:: Adding incorrect wire protocol flags can cause problems and/or extra server load. From 6566f4c51bd469823f2ffd8fb896fd8faa776180 Mon Sep 17 00:00:00 2001 From: kay Date: Wed, 13 Feb 2013 18:39:41 -0500 Subject: [PATCH 4/4] DOCS-860 addOption shorten example to add only one option --- source/reference/method/cursor.addOption.txt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/source/reference/method/cursor.addOption.txt b/source/reference/method/cursor.addOption.txt index 2626028bc76..0517ba081ec 100644 --- a/source/reference/method/cursor.addOption.txt +++ b/source/reference/method/cursor.addOption.txt @@ -19,15 +19,13 @@ cursor.addOption() list, see your :doc:`driver documentation `. The following example in the :program:`mongo` shell adds the - ``DBQuery.Option.tailable`` and ``DBQuery.Option.awaitData`` flags - to ensure the cursor returned from the query is a tailable cursor - that waits for a few seconds when the cursor reaches the end of the - data: + ``DBQuery.Option.tailable`` flag to ensure the cursor returned from + the query is a tailable cursor: .. code-block:: javascript - var cursor = db.myCappedCollection.find().addOption(DBQuery.Option.tailable). - addOption(DBQuery.Option.awaitData); + var t = db.myCappedCollection; + var cursor = t.find().addOption(DBQuery.Option.tailable); .. warning:: Adding incorrect wire protocol flags can cause problems and/or extra server load.