@@ -1685,21 +1685,29 @@ Note that one can also define fields with aliases via the static factory method
1685
1685
====
1686
1686
[source,java]
1687
1687
----
1688
- project("name", "netPrice") // will generate {$project: {name: 1, netPrice: 1}}
1689
- project().and("foo").as("bar") // will generate {$project: {bar: $foo}}
1690
- project("a","b").and("foo").as("bar") // will generate {$project: {a: 1, b: 1, bar: $foo}}
1688
+ // will generate {$project: {name: 1, netPrice: 1}}
1689
+ project("name", "netPrice")
1690
+
1691
+ // will generate {$project: {bar: $foo}}
1692
+ project().and("foo").as("bar")
1693
+
1694
+ // will generate {$project: {a: 1, b: 1, bar: $foo}}
1695
+ project("a","b").and("foo").as("bar")
1691
1696
----
1692
1697
====
1693
1698
1694
1699
.Multi-Stage Aggregation using Projection and Sorting
1695
1700
====
1696
1701
[source,java]
1697
1702
----
1698
- project("name", "netPrice"), sort(ASC, "name") // will generate {$project: {name: 1, netPrice: 1}}, {$sort: {name: 1}}
1703
+ // will generate {$project: {name: 1, netPrice: 1}}, {$sort: {name: 1}}
1704
+ project("name", "netPrice"), sort(ASC, "name")
1699
1705
1700
- project().and("foo").as("bar"), sort(ASC, "bar") // will generate {$project: {bar: $foo}}, {$sort: {bar: 1}}
1706
+ // will generate {$project: {bar: $foo}}, {$sort: {bar: 1}}
1707
+ project().and("foo").as("bar"), sort(ASC, "bar")
1701
1708
1702
- project().and("foo").as("bar"), sort(ASC, "foo") // this will not work
1709
+ // this will not work
1710
+ project().and("foo").as("bar"), sort(ASC, "foo")
1703
1711
----
1704
1712
====
1705
1713
0 commit comments