Skip to content

Commit a0aadd2

Browse files
committed
CSHARP-3145: Fix incorrect example in pipeline documentation
1 parent cba67a3 commit a0aadd2

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

Docs/reference/content/reference/driver/definitions.md

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ title = "Definitions and Builders"
1111

1212
## Definitions and Builders
1313

14-
The driver has introduced a number of types related to the specification of filters, updates, projections, sorts, and index keys. These types are used throughout the [API]({{< relref "reference\driver\crud\index.md" >}}).
14+
The driver has introduced a number of types related to the specification of filters, updates, projections, sorts, and index keys. These types are used throughout the [API]({{< relref "reference\driver\crud\index.md" >}}).
1515

1616
Most of the definitions also have builders to aid in their creation. Each builder has a generic type parameter `TDocument` which represents the type of document with which you are working. It will almost always match the generic `TDocument` parameter used in an [`IMongoCollection<TDocument>`]({{< apiref "T_MongoDB_Driver_IMongoCollection_1" >}}).
1717

@@ -29,11 +29,11 @@ However, if you are working with a [mapped class]({{< relref "reference\bson\map
2929
```csharp
3030
class Person
3131
{
32-
[BsonElement("fn")]
33-
public string FirstName { get; set; }
32+
[BsonElement("fn")]
33+
public string FirstName { get; set; }
3434

35-
[BsonElement("ln")]
36-
public string LastName { get; set; }
35+
[BsonElement("ln")]
36+
public string LastName { get; set; }
3737
}
3838
```
3939

@@ -65,7 +65,7 @@ FilterDefinition<BsonDocument> filter = new BsonDocument("x", 1);
6565
Both of these will render the filter `{ x: 1 }`.
6666

6767

68-
### Filter Definition Builder
68+
### Filter Definition Builder
6969

7070
_See the [tests]({{< testref "MongoDB.Driver.Tests/FilterDefinitionBuilderTests.cs" >}}) for examples._
7171

@@ -85,11 +85,11 @@ Given the following class:
8585
```csharp
8686
class Widget
8787
{
88-
[BsonElement("x")]
89-
public int X { get; set; }
88+
[BsonElement("x")]
89+
public int X { get; set; }
9090

91-
[BsonElement("y")]
92-
public int Y { get; set; }
91+
[BsonElement("y")]
92+
public int Y { get; set; }
9393
}
9494
```
9595

@@ -114,7 +114,7 @@ var filter = builder.Eq("x", 10) & builder.Lt("y", 20);
114114

115115
For more information on valid lambda expressions, see the [expressions documentation]({{< relref "reference\driver\expressions.md" >}}).
116116

117-
#### Array Operators
117+
#### Array Operators
118118

119119
When using entities with properties or fields that serialize to arrays, you can use the methods prefixed with "Any" to compare the entire array against a single item.
120120

@@ -123,7 +123,7 @@ Given the following class:
123123
```csharp
124124
public class Post
125125
{
126-
public IEnumerable<string> Tags { get; set; }
126+
public IEnumerable<string> Tags { get; set; }
127127
}
128128
```
129129

@@ -138,15 +138,15 @@ var filter = Builders<Post>.Filter.AnyEq(x => x.Tags, "mongodb");
138138

139139
## Pipelines
140140

141-
A pipeline definition defines an entire aggregation pipeline. It is implicitly convertible from a [`List<BsonDocument>`]({{< apiref "T_MongoDB_Bson_BsonDocument" >}}), a [`BsonDocument`]({{< apiref "T_MongoDB_Bson_BsonDocument" >}}), a [`List<IPipelineStageDefinition>`]({{< apiref "T_MongoDB_Driver_IPipelineStageDefinition" >}}) , and a [`IPipelineStageDefinition[]`]({{< apiref "T_MongoDB_Driver_IPipelineStageDefinition" >}}).
141+
A pipeline definition defines an entire aggregation pipeline. It is implicitly convertible from a [`List<BsonDocument>`]({{< apiref "T_MongoDB_Bson_BsonDocument" >}}), a [`BsonDocument[]`]({{< apiref "T_MongoDB_Bson_BsonDocument" >}}), a [`List<IPipelineStageDefinition>`]({{< apiref "T_MongoDB_Driver_IPipelineStageDefinition" >}}) , and a [`IPipelineStageDefinition[]`]({{< apiref "T_MongoDB_Driver_IPipelineStageDefinition" >}}).
142142

143143
For example:
144144

145145
```csharp
146-
PipelineDefinition pipeline = new BsonDocument[]
146+
PipelineDefinition<BsonDocument, BsonDocument> pipeline = new BsonDocument[]
147147
{
148-
new BsonDocument { { "$match", new BsonDocument("x", 1) } },
149-
new BsonDocument { { "$sort", new BsonDocument("y", 1) } }
148+
new BsonDocument { { "$match", new BsonDocument("x", 1) } },
149+
new BsonDocument { { "$sort", new BsonDocument("y", 1) } }
150150
};
151151
```
152152

@@ -170,7 +170,7 @@ ProjectionDefinition<BsonDocument> projection = new BsonDocument("x", 1);
170170
Both of these will render the projection `{ x: 1 }`.
171171

172172

173-
### Projection Definition Builder
173+
### Projection Definition Builder
174174

175175
_See the [tests]({{< testref "MongoDB.Driver.Tests/ProjectionDefinitionBuilderTests.cs" >}}) for examples._
176176

@@ -185,13 +185,13 @@ Using the `Widget` class:
185185
```csharp
186186
class Widget
187187
{
188-
public ObjectId Id { get; set; }
188+
public ObjectId Id { get; set; }
189189

190-
[BsonElement("x")]
191-
public int X { get; set; }
190+
[BsonElement("x")]
191+
public int X { get; set; }
192192

193-
[BsonElement("y")]
194-
public int Y { get; set; }
193+
[BsonElement("y")]
194+
public int Y { get; set; }
195195
}
196196
```
197197

@@ -221,7 +221,7 @@ This last projection where we've used the [`Expression`]({{< apiref "M_MongoDB_D
221221
The driver supports using expression trees to render projections. The same expression tree will sometimes render differently when used in a Find operation versus when used in an Aggregate operation. Inherently, a lambda expression contains all the information necessary to form both the projection on the server as well as the client-side result and requires no further information.
222222

223223

224-
##### Find
224+
##### Find
225225

226226
_See the [tests]({{< testref "MongoDB.Driver.Tests/Linq/Translators/FindProjectionTranslatorTests.cs" >}}) for examples._
227227

@@ -232,13 +232,13 @@ Given the following class:
232232
```csharp
233233
class Widget
234234
{
235-
public ObjectId Id { get; set; }
235+
public ObjectId Id { get; set; }
236236

237-
[BsonElement("x")]
238-
public int X { get; set; }
237+
[BsonElement("x")]
238+
public int X { get; set; }
239239

240-
[BsonElement("y")]
241-
public int Y { get; set; }
240+
[BsonElement("y")]
241+
public int Y { get; set; }
242242
}
243243
```
244244

@@ -257,18 +257,18 @@ var projection = Builders<Widget>.Projection.Expression(x => (x.X + x.Y) / 2);
257257
The `_id` field is excluded automatically when we know for certain that it isn't necessary, as is the case in all the above examples.
258258

259259

260-
##### Aggregate
260+
##### Aggregate
261261

262262
_See the [tests]({{< testref "MongoDB.Driver.Tests/Linq/Translators/AggregateProjectionTranslatorTests_Project.cs" >}}) for examples._
263263

264264
When an aggregate projection is defined using a lambda expression, a majority of the [aggregation expression operators]({{< docsref "reference/operator/aggregation/#expression-operators" >}}) are supported and translated. Unlike a project for Find, no part of the lambda expression is run client-side. This means that all expressions in a projection for the [Aggregation Framework]({{< docsref "core/aggregation-pipeline/" >}}) must be expressible on the server.
265265

266266

267-
##### Grouping
267+
##### Grouping
268268

269269
_See the [tests]({{< testref "MongoDB.Driver.Tests/Linq/Translators/AggregateProjectionTranslatorTests_Group.cs" >}}) for examples._
270270

271-
A projection is also used when performing grouping in the [Aggregation Framework]({{< docsref "core/aggregation-pipeline/" >}}). In addition to the expression operators used in an aggregate projection, the [aggregation accumulator operators]({{< docsref "reference/operator/aggregation/group/#accumulator-operator" >}}) are also supported.
271+
A projection is also used when performing grouping in the [Aggregation Framework]({{< docsref "core/aggregation-pipeline/" >}}). In addition to the expression operators used in an aggregate projection, the [aggregation accumulator operators]({{< docsref "reference/operator/aggregation/group/#accumulator-operator" >}}) are also supported.
272272

273273

274274
## Sorts
@@ -285,7 +285,7 @@ SortDefinition<BsonDocument> sort = new BsonDocument("x", 1);
285285

286286
Both of these will render the sort `{ x: 1 }`.
287287

288-
### Sort Definition Builder
288+
### Sort Definition Builder
289289

290290
_See the [tests]({{< testref "MongoDB.Driver.Tests/SortDefinitionBuilderTests.cs" >}}) for examples._
291291

@@ -303,11 +303,11 @@ Given the following class:
303303
```csharp
304304
class Widget
305305
{
306-
[BsonElement("x")]
307-
public int X { get; set; }
306+
[BsonElement("x")]
307+
public int X { get; set; }
308308

309-
[BsonElement("y")]
310-
public int Y { get; set; }
309+
[BsonElement("y")]
310+
public int Y { get; set; }
311311
}
312312
```
313313

@@ -329,7 +329,7 @@ var sort = builder.Ascending("x").Descending("y");
329329

330330
## Updates
331331

332-
[`UpdateDefinition<TDocument>`]({{< apiref "T_MongoDB_Driver_UpdateDefinition_1" >}}) defines how to render a valid update document. It is implicity convertible from both a JSON string as well as a [`BsonDocument`]({{< apiref "T_MongoDB_Bson_BsonDocument" >}}).
332+
[`UpdateDefinition<TDocument>`]({{< apiref "T_MongoDB_Driver_UpdateDefinition_1" >}}) defines how to render a valid update document. It is implicity convertible from both a JSON string as well as a [`BsonDocument`]({{< apiref "T_MongoDB_Bson_BsonDocument" >}}).
333333

334334
```csharp
335335
// invocation
@@ -343,7 +343,7 @@ UpdateDefinition<BsonDocument> update = new BsonDocument("$set", new BsonDocumen
343343
Both of these will render the update `{ $set: { x: 1 } }`.
344344

345345

346-
### Update Definition Builder
346+
### Update Definition Builder
347347

348348
_See the [tests]({{< testref "MongoDB.Driver.Tests/UpdateDefinitionBuilderTests.cs" >}}) for examples._
349349

@@ -403,7 +403,7 @@ IndexKeysDefinition<BsonDocument> keys = new BsonDocument("x", 1);
403403
Both of these will render the keys `{ x: 1 }`.
404404

405405

406-
### Index Keys Definition Builder
406+
### Index Keys Definition Builder
407407

408408
_See the [tests]({{< testref "MongoDB.Driver.Tests/IndexKeysDefinitionBuilderTests.cs" >}}) for examples._
409409

@@ -421,11 +421,11 @@ Given the following class:
421421
```csharp
422422
class Widget
423423
{
424-
[BsonElement("x")]
425-
public int X { get; set; }
424+
[BsonElement("x")]
425+
public int X { get; set; }
426426

427-
[BsonElement("y")]
428-
public int Y { get; set; }
427+
[BsonElement("y")]
428+
public int Y { get; set; }
429429
}
430430
```
431431

@@ -468,4 +468,4 @@ var keys = builder.Wildcard();
468468

469469
// A single field path
470470
var keys = builder.Wildcard(x => x.X);
471-
```
471+
```

0 commit comments

Comments
 (0)