Skip to content

Commit 50a2fb0

Browse files
authored
DOCSP23123 reformatting code example (#5078)
* DOCSP23123 reformatting code example * DOCSP-23123 copy edits * DOCSP-23123 updating number type
1 parent 222a3f6 commit 50a2fb0

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

source/includes/fact-group-sales-documents.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ In :binary:`~bin.mongosh`, create a sample collection named
44
.. code-block:: javascript
55
66
db.sales.insertMany([
7-
{ "_id" : 1, "item" : "abc", "price" : NumberDecimal("10"), "quantity" : NumberInt("2"), "date" : ISODate("2014-03-01T08:00:00Z") },
8-
{ "_id" : 2, "item" : "jkl", "price" : NumberDecimal("20"), "quantity" : NumberInt("1"), "date" : ISODate("2014-03-01T09:00:00Z") },
9-
{ "_id" : 3, "item" : "xyz", "price" : NumberDecimal("5"), "quantity" : NumberInt( "10"), "date" : ISODate("2014-03-15T09:00:00Z") },
10-
{ "_id" : 4, "item" : "xyz", "price" : NumberDecimal("5"), "quantity" : NumberInt("20") , "date" : ISODate("2014-04-04T11:21:39.736Z") },
11-
{ "_id" : 5, "item" : "abc", "price" : NumberDecimal("10"), "quantity" : NumberInt("10") , "date" : ISODate("2014-04-04T21:23:13.331Z") },
12-
{ "_id" : 6, "item" : "def", "price" : NumberDecimal("7.5"), "quantity": NumberInt("5" ) , "date" : ISODate("2015-06-04T05:08:13Z") },
13-
{ "_id" : 7, "item" : "def", "price" : NumberDecimal("7.5"), "quantity": NumberInt("10") , "date" : ISODate("2015-09-10T08:43:00Z") },
14-
{ "_id" : 8, "item" : "abc", "price" : NumberDecimal("10"), "quantity" : NumberInt("5" ) , "date" : ISODate("2016-02-06T20:20:13Z") },
7+
{ "_id" : 1, "item" : "abc", "price" : Decimal128("10"), "quantity" : Int32("2"), "date" : ISODate("2014-03-01T08:00:00Z") },
8+
{ "_id" : 2, "item" : "jkl", "price" : Decimal128("20"), "quantity" : Int32("1"), "date" : ISODate("2014-03-01T09:00:00Z") },
9+
{ "_id" : 3, "item" : "xyz", "price" : Decimal128("5"), "quantity" : Int32( "10"), "date" : ISODate("2014-03-15T09:00:00Z") },
10+
{ "_id" : 4, "item" : "xyz", "price" : Decimal128("5"), "quantity" : Int32("20") , "date" : ISODate("2014-04-04T11:21:39.736Z") },
11+
{ "_id" : 5, "item" : "abc", "price" : Decimal128("10"), "quantity" : Int32("10") , "date" : ISODate("2014-04-04T21:23:13.331Z") },
12+
{ "_id" : 6, "item" : "def", "price" : Decimal128("7.5"), "quantity": Int32("5" ) , "date" : ISODate("2015-06-04T05:08:13Z") },
13+
{ "_id" : 7, "item" : "def", "price" : Decimal128("7.5"), "quantity": Int32("10") , "date" : ISODate("2015-09-10T08:43:00Z") },
14+
{ "_id" : 8, "item" : "abc", "price" : Decimal128("10"), "quantity" : Int32("5" ) , "date" : ISODate("2016-02-06T20:20:13Z") },
1515
])

source/reference/operator/aggregation/group.txt

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ The operation returns the following result:
264264
.. code-block:: javascript
265265
:copyable: false
266266

267-
{ "_id" : "abc", "totalSaleAmount" : NumberDecimal("170") }
268-
{ "_id" : "xyz", "totalSaleAmount" : NumberDecimal("150") }
269-
{ "_id" : "def", "totalSaleAmount" : NumberDecimal("112.5") }
267+
{ "_id" : "abc", "totalSaleAmount" : Decimal128("170") }
268+
{ "_id" : "xyz", "totalSaleAmount" : Decimal128("150") }
269+
{ "_id" : "def", "totalSaleAmount" : Decimal128("112.5") }
270270

271271
This aggregation operation is equivalent to the following SQL statement:
272272

@@ -335,9 +335,21 @@ The operation returns the following results:
335335
.. code-block:: javascript
336336
:copyable: false
337337

338-
{ "_id" : "2014-04-04", "totalSaleAmount" : NumberDecimal("200"), "averageQuantity" : 15, "count" : 2 }
339-
{ "_id" : "2014-03-15", "totalSaleAmount" : NumberDecimal("50"), "averageQuantity" : 10, "count" : 1 }
340-
{ "_id" : "2014-03-01", "totalSaleAmount" : NumberDecimal("40"), "averageQuantity" : 1.5, "count" : 2 }
338+
{
339+
"_id" : "2014-04-04",
340+
"totalSaleAmount" : Decimal128("200"),
341+
"averageQuantity" : 15, "count" : 2
342+
}
343+
{
344+
"_id" : "2014-03-15",
345+
"totalSaleAmount" : Decimal128("50"),
346+
"averageQuantity" : 10, "count" : 1
347+
}
348+
{
349+
"_id" : "2014-03-01",
350+
"totalSaleAmount" : Decimal128("40"),
351+
"averageQuantity" : 1.5, "count" : 2
352+
}
341353

342354
This aggregation operation is equivalent to the following SQL statement:
343355

@@ -348,7 +360,7 @@ This aggregation operation is equivalent to the following SQL statement:
348360
Avg(quantity) AS averageQuantity,
349361
Count(*) AS Count
350362
FROM sales
351-
WHERE date >= '01/01/2014' AND date < '01/01/2015'
363+
WHERE date >= '01/01/2014' AND date < '01/01/2015'
352364
GROUP BY date
353365
ORDER BY totalSaleAmount DESC
354366

@@ -388,7 +400,7 @@ The operation returns the following result:
388400

389401
{
390402
"_id" : null,
391-
"totalSaleAmount" : NumberDecimal("452.5"),
403+
"totalSaleAmount" : Decimal128("452.5"),
392404
"averageQuantity" : 7.875,
393405
"count" : 8
394406
}

0 commit comments

Comments
 (0)