Skip to content

Commit 9b59482

Browse files
CSHARP-4187: MongoDB .NET Driver Quick Tour - Query Example Consistency. (#815)
1 parent 5fbacbb commit 9b59482

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Docs/reference/content/getting_started/quick_tour.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ Each of the above examples will print the exact same thing to the console. For m
207207
We can create a filter to pass to the [`Find`]({{< apiref "Overload_MongoDB_Driver_IMongoCollectionExtensions_Find" >}}) method to get a subset of the documents in our collection. For example, if we wanted to find the document for which the value of the “i” field is 71, we would do the following:
208208

209209
```csharp
210-
var filter = Builders<BsonDocument>.Filter.Eq("i", 71);
210+
var filter = Builders<BsonDocument>.Filter.Eq("counter", 71);
211211
```
212212
```csharp
213213
var document = collection.Find(filter).First();
@@ -221,7 +221,7 @@ Console.WriteLine(document);
221221
and it should print just one document:
222222

223223
```json
224-
{ "_id" : ObjectId("5515836e58c7b4fbc756320b"), "i" : 71 }
224+
{ "_id" : ObjectId("5515836e58c7b4fbc756320b"), "counter" : 71 }
225225
```
226226

227227
{{% note %}}Use the [Filter]({{< relref "reference\driver\definitions.md#filters" >}}), [Sort]({{< relref "reference\driver\definitions.md#sorts" >}}), and [Projection]({{< relref "reference\driver\definitions.md#projections" >}}) builders for simple and concise ways of building up queries.{{% /note %}}
@@ -231,7 +231,7 @@ and it should print just one document:
231231
We can also get a set of documents from our collection. For example, if we wanted to get all documents where `i > 50`, we could write:
232232

233233
```csharp
234-
var filter = Builders<BsonDocument>.Filter.Gt("i", 50);
234+
var filter = Builders<BsonDocument>.Filter.Gt("counter", 50);
235235
```
236236
```csharp
237237
var cursor = collection.Find(filter).ToCursor();
@@ -248,7 +248,7 @@ We could also get a range, say `50 < i <= 100`:
248248

249249
```csharp
250250
var filterBuilder = Builders<BsonDocument>.Filter;
251-
var filter = filterBuilder.Gt("i", 50) & filterBuilder.Lte("i", 100);
251+
var filter = filterBuilder.Gt("counter", 50) & filterBuilder.Lte("counter", 100);
252252
```
253253
```csharp
254254
var cursor = collection.Find(filter).ToCursor();
@@ -266,8 +266,8 @@ await collection.Find(filter).ForEachAsync(document => Console.WriteLine(documen
266266
We add a sort to a find query by calling the [`Sort`]({{< apiref "M_MongoDB_Driver_IFindFluent_2_Sort" >}}) method. Below we use the [`Exists`]({{< apiref "Overload_MongoDB_Driver_FilterDefinitionBuilder_1_Exists" >}}) filter builder method and [`Descending`]({{< apiref "Overload_MongoDB_Driver_SortDefinitionBuilder_1_Descending" >}}) sort builder method to sort our documents:
267267

268268
```csharp
269-
var filter = Builders<BsonDocument>.Filter.Exists("i");
270-
var sort = Builders<BsonDocument>.Sort.Descending("i");
269+
var filter = Builders<BsonDocument>.Filter.Exists("counter");
270+
var sort = Builders<BsonDocument>.Sort.Descending("counter");
271271
```
272272
```csharp
273273
var document = collection.Find(filter).Sort(sort).First();
@@ -299,8 +299,8 @@ There are numerous [update operators](https://www.mongodb.com/docs/manual/refere
299299
To update at most 1 document (may be 0 if none match the filter), use the [`UpdateOne`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_UpdateOne" >}}) or [`UpdateOneAsync`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_UpdateOneAsync" >}}) methods to specify the filter and the update document. Here we update the first document that meets the filter `i == 10` and set the value of `i` to `110`:
300300

301301
```csharp
302-
var filter = Builders<BsonDocument>.Filter.Eq("i", 10);
303-
var update = Builders<BsonDocument>.Update.Set("i", 110);
302+
var filter = Builders<BsonDocument>.Filter.Eq("counter", 10);
303+
var update = Builders<BsonDocument>.Update.Set("counter", 110);
304304
```
305305
```csharp
306306
collection.UpdateOne(filter, update);
@@ -312,8 +312,8 @@ await collection.UpdateOneAsync(filter, update);
312312
To update all documents matching the filter use the [`UpdateMany`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_UpdateMany" >}}) or [`UpdateManyAsync`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_UpdateManyAsync" >}}) methods. Here we increment the value of `i` by `100` where `i < 100`.
313313

314314
```csharp
315-
var filter = Builders<BsonDocument>.Filter.Lt("i", 100);
316-
var update = Builders<BsonDocument>.Update.Inc("i", 100);
315+
var filter = Builders<BsonDocument>.Filter.Lt("counter", 100);
316+
var update = Builders<BsonDocument>.Update.Inc("counter", 100);
317317
```
318318
```csharp
319319
var result = collection.UpdateMany(filter, update);
@@ -341,7 +341,7 @@ The update methods return an [`UpdateResult`]({{< apiref "T_MongoDB_Driver_Updat
341341
To delete at most 1 document (may be 0 if none match the filter) use the [`DeleteOne`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_DeleteOne" >}}) or [`DeleteOneAsync`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_DeleteOneAsync" >}}) methods:
342342

343343
```csharp
344-
var filter = Builders<BsonDocument>.Filter.Eq("i", 110);
344+
var filter = Builders<BsonDocument>.Filter.Eq("counter", 110);
345345
```
346346
```csharp
347347
collection.DeleteOne(filter);
@@ -353,7 +353,7 @@ await collection.DeleteOneAsync(filter);
353353
To delete all documents matching the filter use the [`DeleteMany`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_DeleteMany" >}}) or [`DeleteManyAsync`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_DeleteManyAsync" >}}) methods. Here we delete all documents where `i >= 100`:
354354

355355
```csharp
356-
var filter = Builders<BsonDocument>.Filter.Gte("i", 100);
356+
var filter = Builders<BsonDocument>.Filter.Gte("counter", 100);
357357
```
358358
```csharp
359359
var result = collection.DeleteMany(filter);

0 commit comments

Comments
 (0)