Skip to content

Commit 14d62e6

Browse files
move sync above async (#538) (#540)
* move sync above async * add back word (cherry picked from commit 22346ac) Co-authored-by: shuangela <[email protected]>
1 parent aea14d7 commit 14d62e6

File tree

17 files changed

+414
-431
lines changed

17 files changed

+414
-431
lines changed

source/fundamentals/crud/read-operations/change-streams.txt

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,11 @@ classes:
6565
- ``Collection``: To monitor changes in the collection
6666

6767
The following example opens a change stream on the ``restaurants`` collection
68-
and outputs the changes as they occur. Select the
69-
:guilabel:`Asynchronous` or :guilabel:`Synchronous` tab to see the corresponding
70-
code.
68+
and outputs the changes as they occur. Select the :guilabel:`Synchronous` or
69+
:guilabel:`Asynchronous` tab to see the corresponding code.
7170

7271
.. tabs::
7372

74-
.. tab:: Asynchronous
75-
:tabid: change-stream-async
76-
77-
.. literalinclude:: /includes/code-examples/change-streams/change-streams.cs
78-
:start-after: start-open-change-stream-async
79-
:end-before: end-open-change-stream-async
80-
:language: csharp
81-
8273
.. tab:: Synchronous
8374
:tabid: change-stream-sync
8475

@@ -87,6 +78,14 @@ code.
8778
:end-before: end-open-change-stream
8879
:language: csharp
8980

81+
.. tab:: Asynchronous
82+
:tabid: change-stream-async
83+
84+
.. literalinclude:: /includes/code-examples/change-streams/change-streams.cs
85+
:start-after: start-open-change-stream-async
86+
:end-before: end-open-change-stream-async
87+
:language: csharp
88+
9089
To begin watching for changes, run the application. Then, in a separate
9190
application or shell, modify the ``restaurants`` collection. Updating a document
9291
that has a ``"name"`` value of ``"Blarney Castle"`` results in the following
@@ -134,20 +133,12 @@ You can specify the following aggregation stages in the ``pipeline`` parameter:
134133
Monitor Update Events Example
135134
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
136135

137-
The following example uses the ``pipeline`` parameter to open a change stream
138-
that records only update operations. Select the :guilabel:`Asynchronous` or :guilabel:`Synchronous` tab to see the
139-
corresponding code.
136+
The following example uses the ``pipeline`` parameter to open a change stream that records
137+
only update operations. Select the :guilabel:`Synchronous` or :guilabel:`Asynchronous` tab
138+
to see the corresponding code.
140139

141140
.. tabs::
142141

143-
.. tab:: Asynchronous
144-
:tabid: change-stream-async
145-
146-
.. literalinclude:: /includes/code-examples/change-streams/change-streams.cs
147-
:start-after: start-change-stream-pipeline-async
148-
:end-before: end-change-stream-pipeline-async
149-
:language: csharp
150-
151142
.. tab:: Synchronous
152143
:tabid: change-stream-sync
153144

@@ -156,6 +147,14 @@ corresponding code.
156147
:end-before: end-change-stream-pipeline
157148
:language: csharp
158149

150+
.. tab:: Asynchronous
151+
:tabid: change-stream-async
152+
153+
.. literalinclude:: /includes/code-examples/change-streams/change-streams.cs
154+
:start-after: start-change-stream-pipeline-async
155+
:end-before: end-change-stream-pipeline-async
156+
:language: csharp
157+
159158
Split Large Change Events Example
160159
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
161160

@@ -173,14 +172,6 @@ reassemble any event fragments:
173172

174173
.. tabs::
175174

176-
.. tab:: Asynchronous
177-
:tabid: change-stream-split-async
178-
179-
.. literalinclude:: /includes/code-examples/change-streams/change-streams.cs
180-
:start-after: start-split-change-event-async
181-
:end-before: end-split-change-event-async
182-
:language: csharp
183-
184175
.. tab:: Synchronous
185176
:tabid: change-stream-split-sync
186177

@@ -189,6 +180,14 @@ reassemble any event fragments:
189180
:end-before: end-split-change-event-sync
190181
:language: csharp
191182

183+
.. tab:: Asynchronous
184+
:tabid: change-stream-split-async
185+
186+
.. literalinclude:: /includes/code-examples/change-streams/change-streams.cs
187+
:start-after: start-split-change-event-async
188+
:end-before: end-split-change-event-async
189+
:language: csharp
190+
192191
.. note::
193192

194193
We recommend reassembling change event fragments, as shown in the
@@ -202,6 +201,14 @@ The following code defines these methods:
202201

203202
.. tabs::
204203

204+
.. tab:: Synchronous
205+
:tabid: split-event-helpers-sync
206+
207+
.. literalinclude:: /includes/code-examples/change-streams/change-streams.cs
208+
:start-after: start-split-event-helpers-sync
209+
:end-before: end-split-event-helpers-sync
210+
:language: csharp
211+
205212
.. tab:: Asynchronous
206213
:tabid: split-event-helpers-async
207214

@@ -210,14 +217,6 @@ The following code defines these methods:
210217
:end-before: end-split-event-helpers-async
211218
:language: csharp
212219

213-
.. tab:: Synchronous
214-
:tabid: split-event-helpers-sync
215-
216-
.. literalinclude:: /includes/code-examples/change-streams/change-streams.cs
217-
:start-after: start-split-event-helpers-sync
218-
:end-before: end-split-event-helpers-sync
219-
:language: csharp
220-
221220
.. tip::
222221

223222
To learn more about splitting large change events, see
@@ -344,19 +343,11 @@ one of the following values:
344343

345344
The following example opens a change stream on a collection and includes the post-image
346345
of updated documents by specifying the ``FullDocument`` option. Select the
347-
:guilabel:`Asynchronous` or :guilabel:`Synchronous` tab to see the corresponding
346+
:guilabel:`Synchronous` or :guilabel:`Asynchronous` tab to see the corresponding
348347
code.
349348

350349
.. tabs::
351350

352-
.. tab:: Asynchronous
353-
:tabid: change-stream-async
354-
355-
.. literalinclude:: /includes/code-examples/change-streams/change-streams.cs
356-
:start-after: start-change-stream-post-image-async
357-
:end-before: end-change-stream-post-image-async
358-
:language: csharp
359-
360351
.. tab:: Synchronous
361352
:tabid: change-stream-sync
362353

@@ -365,6 +356,14 @@ code.
365356
:end-before: end-change-stream-post-image
366357
:language: csharp
367358

359+
.. tab:: Asynchronous
360+
:tabid: change-stream-async
361+
362+
.. literalinclude:: /includes/code-examples/change-streams/change-streams.cs
363+
:start-after: start-change-stream-post-image-async
364+
:end-before: end-change-stream-post-image-async
365+
:language: csharp
366+
368367
Running the preceding code example and updating a document that has a ``"name"``
369368
value of ``"Blarney Castle"`` results in the following change stream output:
370369

source/fundamentals/crud/read-operations/distinct.txt

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,20 @@ Retrieve Values Across a Collection
5656
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5757

5858
The following example retrieves the distinct values of the ``borough`` field in
59-
the ``restaurants`` collection. Select the :guilabel:`Asynchronous` or :guilabel:`Synchronous`
59+
the ``restaurants`` collection. Select the :guilabel:`Synchronous` or :guilabel:`Asynchronous`
6060
tab to see the corresponding code.
6161

6262
.. tabs::
6363

64-
.. tab:: Asynchronous
65-
:tabid: distinct-async
64+
.. tab:: Synchronous
65+
:tabid: distinct-sync
6666

6767
.. io-code-block::
6868
:copyable:
6969

7070
.. input:: /includes/fundamentals/code-examples/Distinct.cs
71-
:start-after: start-distinct-async
72-
:end-before: end-distinct-async
71+
:start-after: start-distinct
72+
:end-before: end-distinct
7373
:language: csharp
7474
:dedent:
7575

@@ -83,15 +83,15 @@ tab to see the corresponding code.
8383
Queens
8484
Staten Island
8585

86-
.. tab:: Synchronous
87-
:tabid: distinct-sync
86+
.. tab:: Asynchronous
87+
:tabid: distinct-async
8888

8989
.. io-code-block::
9090
:copyable:
9191

9292
.. input:: /includes/fundamentals/code-examples/Distinct.cs
93-
:start-after: start-distinct
94-
:end-before: end-distinct
93+
:start-after: start-distinct-async
94+
:end-before: end-distinct-async
9595
:language: csharp
9696
:dedent:
9797

@@ -119,19 +119,19 @@ For more information about creating a query filter, see the :ref:`csharp-specify
119119

120120
The following example retrieves the distinct values of the ``borough`` field for
121121
all documents that have a ``cuisine`` field value of ``"Italian"``. Select the
122-
:guilabel:`Asynchronous` or :guilabel:`Synchronous` tab to see the corresponding code.
122+
:guilabel:`Synchronous` or :guilabel:`Asynchronous` tab to see the corresponding code.
123123

124124
.. tabs::
125-
126-
.. tab:: Asynchronous
127-
:tabid: distinct-async
125+
126+
.. tab:: Synchronous
127+
:tabid: distinct-sync
128128

129129
.. io-code-block::
130130
:copyable:
131131

132132
.. input:: /includes/fundamentals/code-examples/Distinct.cs
133-
:start-after: start-distinct-with-query-async
134-
:end-before: end-distinct-with-query-async
133+
:start-after: start-distinct-with-query
134+
:end-before: end-distinct-with-query
135135
:language: csharp
136136
:dedent:
137137

@@ -143,16 +143,16 @@ all documents that have a ``cuisine`` field value of ``"Italian"``. Select the
143143
Manhattan
144144
Queens
145145
Staten Island
146-
147-
.. tab:: Synchronous
148-
:tabid: distinct-sync
146+
147+
.. tab:: Asynchronous
148+
:tabid: distinct-async
149149

150150
.. io-code-block::
151151
:copyable:
152152

153153
.. input:: /includes/fundamentals/code-examples/Distinct.cs
154-
:start-after: start-distinct-with-query
155-
:end-before: end-distinct-with-query
154+
:start-after: start-distinct-with-query-async
155+
:end-before: end-distinct-with-query-async
156156
:language: csharp
157157
:dedent:
158158

@@ -196,20 +196,20 @@ all documents that have a ``borough`` field value of ``"Bronx"`` and a
196196
``cuisine`` field value of ``"Pizza"``. Then, it adds a comment to the operation by
197197
providing a ``DistinctOptions`` instance to the ``Distinct()`` method.
198198

199-
Select the :guilabel:`Asynchronous` or :guilabel:`Synchronous` tab to see the
199+
Select the :guilabel:`Synchronous` or :guilabel:`Asynchronous` tab to see the
200200
corresponding code.
201201

202202
.. tabs::
203-
204-
.. tab:: Asynchronous
205-
:tabid: distinct-async
203+
204+
.. tab:: Synchronous
205+
:tabid: distinct-sync
206206

207207
.. io-code-block::
208208
:copyable:
209209

210210
.. input:: /includes/fundamentals/code-examples/Distinct.cs
211-
:start-after: start-distinct-with-comment-async
212-
:end-before: end-distinct-with-comment-async
211+
:start-after: start-distinct-with-comment
212+
:end-before: end-distinct-with-comment
213213
:language: csharp
214214
:dedent:
215215

@@ -224,16 +224,16 @@ corresponding code.
224224
Amici Pizza And Pasta
225225
Angie'S Cafe Pizza
226226
...
227-
228-
.. tab:: Synchronous
229-
:tabid: distinct-sync
227+
228+
.. tab:: Asynchronous
229+
:tabid: distinct-async
230230

231231
.. io-code-block::
232232
:copyable:
233233

234234
.. input:: /includes/fundamentals/code-examples/Distinct.cs
235-
:start-after: start-distinct-with-comment
236-
:end-before: end-distinct-with-comment
235+
:start-after: start-distinct-with-comment-async
236+
:end-before: end-distinct-with-comment-async
237237
:language: csharp
238238
:dedent:
239239

source/fundamentals/crud/read-operations/retrieve.txt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,21 @@ results. If no documents match the query filter the methods return ``null``.
8686

8787
.. tabs::
8888

89-
.. tab:: Asynchronous
90-
:tabid: find-one-async
89+
.. tab:: Synchronous
90+
:tabid: find-one-sync
9191

9292
.. code-block:: csharp
9393
:copyable: true
9494

95-
var restaurants = await _restaurantsCollection.Find(filter).FirstOrDefaultAsync();
95+
var restaurants = _restaurantsCollection.Find(filter).FirstOrDefault();
9696

97-
.. tab:: Synchronous
98-
:tabid: find-one-sync
97+
.. tab:: Asynchronous
98+
:tabid: find-one-async
9999

100100
.. code-block:: csharp
101101
:copyable: true
102102

103-
var restaurants = _restaurantsCollection.Find(filter).FirstOrDefault();
103+
var restaurants = await _restaurantsCollection.Find(filter).FirstOrDefaultAsync();
104104

105105
.. tip:: First Document
106106

@@ -133,21 +133,21 @@ To view a synchronous or asynchronous example, select the corresponding tab.
133133

134134
.. tabs::
135135

136-
.. tab:: Asynchronous
137-
:tabid: find-cursor-async
136+
.. tab:: Synchronous
137+
:tabid: find-cursor-sync
138138

139139
.. code-block:: csharp
140140
:copyable: true
141141

142-
var restaurants = await _restaurantsCollection.Find(filter).ToCursorAsync();
142+
var restaurants = _restaurantsCollection.Find(filter).ToCursor();
143143

144-
.. tab:: Synchronous
145-
:tabid: find-cursor-sync
144+
.. tab:: Asynchronous
145+
:tabid: find-cursor-async
146146

147147
.. code-block:: csharp
148148
:copyable: true
149149

150-
var restaurants = _restaurantsCollection.Find(filter).ToCursor();
150+
var restaurants = await _restaurantsCollection.Find(filter).ToCursorAsync();
151151

152152
If you are returning a small number of documents, or need your results returned
153153
as a ``List`` object, use the ``ToList()`` or ``ToListAsync()`` methods.
@@ -159,19 +159,19 @@ synchronous or asynchronous example, select the corresponding tab.
159159

160160
.. tabs::
161161

162-
.. tab:: Asynchronous
163-
:tabid: find-list-async
162+
.. tab:: Synchronous
163+
:tabid: find-list-sync
164164

165165
.. code-block:: csharp
166166

167-
var restaurants = await _restaurantsCollection.Find(filter).ToListAsync();
167+
var restaurants = _restaurantsCollection.Find(filter).ToList();
168168

169-
.. tab:: Synchronous
170-
:tabid: find-list-sync
169+
.. tab:: Asynchronous
170+
:tabid: find-list-async
171171

172172
.. code-block:: csharp
173173

174-
var restaurants = _restaurantsCollection.Find(filter).ToList();
174+
var restaurants = await _restaurantsCollection.Find(filter).ToListAsync();
175175

176176
To see a full example of using the ``Find()`` method to find multiple documents,
177177
see :ref:`csharp-retrieve-additional-information`.

0 commit comments

Comments
 (0)