Skip to content

Commit 4f08d12

Browse files
authored
DOCSP23123 reformatting code example (#5078) (#5210)
* DOCSP23123 reformatting code example * DOCSP-23123 copy edits * DOCSP-23123 updating number type
1 parent a045de4 commit 4f08d12

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
@@ -245,9 +245,9 @@ The operation returns the following result:
245245
.. code-block:: javascript
246246
:copyable: false
247247

248-
{ "_id" : "abc", "totalSaleAmount" : NumberDecimal("170") }
249-
{ "_id" : "xyz", "totalSaleAmount" : NumberDecimal("150") }
250-
{ "_id" : "def", "totalSaleAmount" : NumberDecimal("112.5") }
248+
{ "_id" : "abc", "totalSaleAmount" : Decimal128("170") }
249+
{ "_id" : "xyz", "totalSaleAmount" : Decimal128("150") }
250+
{ "_id" : "def", "totalSaleAmount" : Decimal128("112.5") }
251251

252252
This aggregation operation is equivalent to the following SQL statement:
253253

@@ -316,9 +316,21 @@ The operation returns the following results:
316316
.. code-block:: javascript
317317
:copyable: false
318318

319-
{ "_id" : "2014-04-04", "totalSaleAmount" : NumberDecimal("200"), "averageQuantity" : 15, "count" : 2 }
320-
{ "_id" : "2014-03-15", "totalSaleAmount" : NumberDecimal("50"), "averageQuantity" : 10, "count" : 1 }
321-
{ "_id" : "2014-03-01", "totalSaleAmount" : NumberDecimal("40"), "averageQuantity" : 1.5, "count" : 2 }
319+
{
320+
"_id" : "2014-04-04",
321+
"totalSaleAmount" : Decimal128("200"),
322+
"averageQuantity" : 15, "count" : 2
323+
}
324+
{
325+
"_id" : "2014-03-15",
326+
"totalSaleAmount" : Decimal128("50"),
327+
"averageQuantity" : 10, "count" : 1
328+
}
329+
{
330+
"_id" : "2014-03-01",
331+
"totalSaleAmount" : Decimal128("40"),
332+
"averageQuantity" : 1.5, "count" : 2
333+
}
322334

323335
This aggregation operation is equivalent to the following SQL statement:
324336

@@ -329,7 +341,7 @@ This aggregation operation is equivalent to the following SQL statement:
329341
Avg(quantity) AS averageQuantity,
330342
Count(*) AS Count
331343
FROM sales
332-
WHERE date >= '01/01/2014' AND date < '01/01/2015'
344+
WHERE date >= '01/01/2014' AND date < '01/01/2015'
333345
GROUP BY date
334346
ORDER BY totalSaleAmount DESC
335347

@@ -369,7 +381,7 @@ The operation returns the following result:
369381

370382
{
371383
"_id" : null,
372-
"totalSaleAmount" : NumberDecimal("452.5"),
384+
"totalSaleAmount" : Decimal128("452.5"),
373385
"averageQuantity" : 7.875,
374386
"count" : 8
375387
}

0 commit comments

Comments
 (0)