Skip to content

Commit ab7e2cb

Browse files
authored
DOCSP23123 reformatting code example (#5078) (#5208)
* DOCSP23123 reformatting code example * DOCSP-23123 copy edits * DOCSP-23123 updating number type
1 parent 2509a05 commit ab7e2cb

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
@@ -260,9 +260,9 @@ The operation returns the following result:
260260
.. code-block:: javascript
261261
:copyable: false
262262

263-
{ "_id" : "abc", "totalSaleAmount" : NumberDecimal("170") }
264-
{ "_id" : "xyz", "totalSaleAmount" : NumberDecimal("150") }
265-
{ "_id" : "def", "totalSaleAmount" : NumberDecimal("112.5") }
263+
{ "_id" : "abc", "totalSaleAmount" : Decimal128("170") }
264+
{ "_id" : "xyz", "totalSaleAmount" : Decimal128("150") }
265+
{ "_id" : "def", "totalSaleAmount" : Decimal128("112.5") }
266266

267267
This aggregation operation is equivalent to the following SQL statement:
268268

@@ -331,9 +331,21 @@ The operation returns the following results:
331331
.. code-block:: javascript
332332
:copyable: false
333333

334-
{ "_id" : "2014-04-04", "totalSaleAmount" : NumberDecimal("200"), "averageQuantity" : 15, "count" : 2 }
335-
{ "_id" : "2014-03-15", "totalSaleAmount" : NumberDecimal("50"), "averageQuantity" : 10, "count" : 1 }
336-
{ "_id" : "2014-03-01", "totalSaleAmount" : NumberDecimal("40"), "averageQuantity" : 1.5, "count" : 2 }
334+
{
335+
"_id" : "2014-04-04",
336+
"totalSaleAmount" : Decimal128("200"),
337+
"averageQuantity" : 15, "count" : 2
338+
}
339+
{
340+
"_id" : "2014-03-15",
341+
"totalSaleAmount" : Decimal128("50"),
342+
"averageQuantity" : 10, "count" : 1
343+
}
344+
{
345+
"_id" : "2014-03-01",
346+
"totalSaleAmount" : Decimal128("40"),
347+
"averageQuantity" : 1.5, "count" : 2
348+
}
337349

338350
This aggregation operation is equivalent to the following SQL statement:
339351

@@ -344,7 +356,7 @@ This aggregation operation is equivalent to the following SQL statement:
344356
Avg(quantity) AS averageQuantity,
345357
Count(*) AS Count
346358
FROM sales
347-
WHERE date >= '01/01/2014' AND date < '01/01/2015'
359+
WHERE date >= '01/01/2014' AND date < '01/01/2015'
348360
GROUP BY date
349361
ORDER BY totalSaleAmount DESC
350362

@@ -384,7 +396,7 @@ The operation returns the following result:
384396

385397
{
386398
"_id" : null,
387-
"totalSaleAmount" : NumberDecimal("452.5"),
399+
"totalSaleAmount" : Decimal128("452.5"),
388400
"averageQuantity" : 7.875,
389401
"count" : 8
390402
}

0 commit comments

Comments
 (0)