Skip to content

Commit e05553e

Browse files
authored
DOCSP23123 reformatting code example (#5078) (#5211)
* DOCSP23123 reformatting code example * DOCSP-23123 copy edits * DOCSP-23123 updating number type
1 parent 7d96a15 commit e05553e

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 @@ From the :binary:`~bin.mongo` shell, 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
@@ -244,9 +244,9 @@ The operation returns the following result:
244244
.. code-block:: javascript
245245
:copyable: false
246246

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

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

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

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

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

@@ -328,7 +340,7 @@ This aggregation operation is equivalent to the following SQL statement:
328340
Avg(quantity) AS averageQuantity,
329341
Count(*) AS Count
330342
FROM sales
331-
WHERE date >= '01/01/2014' AND date < '01/01/2015'
343+
WHERE date >= '01/01/2014' AND date < '01/01/2015'
332344
GROUP BY date
333345
ORDER BY totalSaleAmount DESC
334346

@@ -368,7 +380,7 @@ The operation returns the following result:
368380

369381
{
370382
"_id" : null,
371-
"totalSaleAmount" : NumberDecimal("452.5"),
383+
"totalSaleAmount" : Decimal128("452.5"),
372384
"averageQuantity" : 7.875,
373385
"count" : 8
374386
}

0 commit comments

Comments
 (0)