Skip to content

Commit ad03b1d

Browse files
committed
CSHARP-2293: Replace Count with CountDocuments in reference documentation.
1 parent 041ed93 commit ad03b1d

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

Docs/reference/content/getting_started/admin_quick_tour.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ collection.InsertMany(new []
176176

177177
// find them using the text index
178178
var filter = Builders<BsonDocument>.Filter.Text("textual content -irrelevant");
179-
var matchCount = collection.Count(filter);
179+
var matchCount = collection.CountDocuments(filter);
180180
Console.WriteLine("Text search matches: {0}", matchCount);
181181

182182
// find them using the text index with the $language operator
183183
var englishFilter = Builders<BsonDocument>.Filter.Text("textual content -irrelevant", "english");
184-
var matchCount = collection.Count(filter);
184+
var matchCount = collection.CountDocuments(filter);
185185
Console.WriteLine("Text search matches (english): {0}", matchCount);
186186

187187
// find the highest scoring match
@@ -200,12 +200,12 @@ await collection.InsertManyAsync(new []
200200

201201
// find them using the text index
202202
var filter = Builders<BsonDocument>.Filter.Text("textual content -irrelevant");
203-
var matchCount = await collection.CountAsync(filter);
203+
var matchCount = await collection.CountDocumentsAsync(filter);
204204
Console.WriteLine("Text search matches: {0}", matchCount);
205205

206206
// find them using the text index with the $language operator
207207
var englishFilter = Builders<BsonDocument>.Filter.Text("textual content -irrelevant", "english");
208-
var matchCount = await collection.CountAsync(filter);
208+
var matchCount = await collection.CountDocumentsAsync(filter);
209209
Console.WriteLine("Text search matches (english): {0}", matchCount);
210210

211211
// find the highest scoring match

Docs/reference/content/getting_started/quick_tour.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,16 @@ await collection.InsertManyAsync(documents);
129129

130130
## Counting Documents
131131

132-
Now that we’ve inserted 101 documents (the 100 we did in the loop, plus the first one), we can check to see if we have them all using the [`Count`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_Count" >}}) or [`CountAsync`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_CountAsync" >}}) methods. The following code should set the value of count to 101.
132+
Now that we’ve inserted 101 documents (the 100 we did in the loop, plus the first one), we can check to see if we have them all using the [`CountDocuments`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_CountDocuments" >}}) or [`CountDocumentsAsync`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_CountDocumentsAsync" >}}) methods. The following code should set the value of count to 101.
133133

134134
```csharp
135-
var count = collection.Count(new BsonDocument());
135+
var count = collection.CountDocuments(new BsonDocument());
136136
```
137137
```csharp
138-
var count = await collection.CountAsync(new BsonDocument());
138+
var count = await collection.CountDocumentsAsync(new BsonDocument());
139139
```
140140

141-
{{% note %}}The empty [`BsonDocument`]({{< apiref "T_MongoDB_Bson_BsonDocument" >}}) parameter to the [`CountAsync`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_CountAsync" >}}) method is a filter. In this case, it is an empty filter indicating to count all the documents.{{% /note %}}
141+
{{% note %}}The empty [`BsonDocument`]({{< apiref "T_MongoDB_Bson_BsonDocument" >}}) parameter to the [`CountDocumentsAsync`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_CountDocumentsAsync" >}}) method is a filter. In this case, it is an empty filter indicating to count all the documents.{{% /note %}}
142142

143143
## Query the Collection
144144

Docs/reference/content/reference/driver/crud/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ title = "Reading and Writing"
1414
All the create, read, update, and delete (CRUD) operations take a similar form and are defined on the [`IMongoCollection<TDocument>`]({{< apiref "T_MongoDB_Driver_IMongoCollection_1" >}}) interface. All the required fields take the form of a positional parameter and, if any options exists, they are passed in as an instance of an options class. All methods are available in both synchronous and asynchronous versions. For example, the following method signatures exists:
1515

1616
```csharp
17-
long Count(FilterDefinition<TDocument> filter, CountOptions options = null);
17+
long CountDocuments(FilterDefinition<TDocument> filter, CountOptions options = null);
1818
```
1919
```csharp
20-
Task<long> CountAsync(FilterDefinition<TDocument> filter, CountOptions options = null);
20+
Task<long> CountDocumentsAsync(FilterDefinition<TDocument> filter, CountOptions options = null);
2121
```
2222

2323
As described, the `filter` is required and the `options` can be omitted.

Docs/reference/content/reference/driver/crud/reading.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,30 @@ title = "Reading"
1010

1111
## Counting Documents
1212

13-
The [`Count`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_Count" >}}) and [`CountAsync`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_CountAsync" >}}) methods can be used to count all the documents matching a particular filter.
13+
The [`CountDocuments`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_CountDocuments" >}}) and [`CountDocumentsAsync`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_CountDocumentsAsync" >}}) methods can be used to count all the documents matching a particular filter.
1414

1515
```csharp
16-
var count = collection.Count(new BsonDocument("x", 10));
16+
var count = collection.CountDocuments(new BsonDocument("x", 10));
1717

1818
// or
1919
20-
var count = collection.Count(x => x.Age > 20);
20+
var count = collection.CountDocuments(x => x.Age > 20);
2121
```
2222
```csharp
23-
var count = await collection.CountAsync(new BsonDocument("x", 10));
23+
var count = await collection.CountDocumentsAsync(new BsonDocument("x", 10));
2424

2525
// or
2626
27-
var count = await collection.CountAsync(x => x.Age > 20);
27+
var count = await collection.CountDocumentsAsync(x => x.Age > 20);
2828
```
2929

3030
Counting all the documents in a collection requires an empty filter:
3131

3232
```csharp
33-
var count = collection.Count(new BsonDocument());
33+
var count = collection.CountDocuments(new BsonDocument());
3434
```
3535
```csharp
36-
var count = await collection.CountAsync(new BsonDocument());
36+
var count = await collection.CountDocumentsAsync(new BsonDocument());
3737
```
3838

3939

0 commit comments

Comments
 (0)