Skip to content

Commit 2418e3d

Browse files
committed
DOCSP-38492 - Aggregation Code Examples (#76)
1 parent 3329dfc commit 2418e3d

File tree

11 files changed

+762
-793
lines changed

11 files changed

+762
-793
lines changed

source/aggregation/aggregation-tutorials/filtered-subset.txt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -163,26 +163,26 @@ Tutorial
163163
:copyable: false
164164

165165
{
166-
person_id: '7363626383',
167-
firstname: 'Carl',
168-
lastname: 'Simmons',
169-
dateofbirth: 1998-12-26T13:13:55.000Z,
170-
vocation: 'ENGINEER'
166+
'person_id': '7363626383',
167+
'firstname': 'Carl',
168+
'lastname': 'Simmons',
169+
'dateofbirth': datetime.datetime(1998, 12, 26, 13, 13, 55),
170+
'vocation': 'ENGINEER'
171171
}
172172
{
173-
person_id: '1723338115',
174-
firstname: 'Olive',
175-
lastname: 'Ranieri',
176-
dateofbirth: 1985-05-12T23:14:30.000Z,
177-
gender: 'FEMALE',
178-
vocation: 'ENGINEER'
173+
'person_id': '1723338115',
174+
'firstname': 'Olive',
175+
'lastname': 'Ranieri',
176+
'dateofbirth': datetime.datetime(1985, 5, 12, 23, 14, 30),
177+
'gender': 'FEMALE',
178+
'vocation': 'ENGINEER'
179179
}
180180
{
181-
person_id: '6392529400',
182-
firstname: 'Elise',
183-
lastname: 'Smith',
184-
dateofbirth: 1972-01-13T09:32:07.000Z,
185-
vocation: 'ENGINEER'
181+
'person_id': '6392529400',
182+
'firstname': 'Elise',
183+
'lastname': 'Smith',
184+
'dateofbirth': datetime.datetime(1972, 1, 13, 9, 32, 7),
185+
'vocation': 'ENGINEER'
186186
}
187187

188188
To view the complete code for this tutorial, see the `Completed Filtered Subset App

source/aggregation/aggregation-tutorials/group-total.txt

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -191,35 +191,35 @@ Tutorial
191191
:copyable: false
192192

193193
{
194-
first_purchase_date: 2020-01-01T08:25:37.000Z,
195-
total_value: 63,
196-
total_orders: 1,
197-
orders: [ { orderdate: 2020-01-01T08:25:37.000Z, value: 63 } ],
198-
customer_id: '[email protected]'
194+
'first_purchase_date': datetime.datetime(2020, 1, 1, 8, 25, 37),
195+
'total_value': 63,
196+
'total_orders': 1,
197+
'orders': [ { 'orderdate': datetime.datetime(2020, 1, 1, 8, 25, 37), 'value': 63 } ],
198+
'customer_id': '[email protected]'
199199
}
200200
{
201-
first_purchase_date: 2020-01-13T09:32:07.000Z,
202-
total_value: 436,
203-
total_orders: 4,
204-
orders: [
205-
{ orderdate: 2020-01-13T09:32:07.000Z, value: 99 },
206-
{ orderdate: 2020-05-30T08:35:52.000Z, value: 231 },
207-
{ orderdate: 2020-10-03T13:49:44.000Z, value: 102 },
208-
{ orderdate: 2020-12-26T08:55:46.000Z, value: 4 }
201+
'first_purchase_date': datetime.datetime(2020, 1, 13, 9, 32, 7),
202+
'total_value': 436,
203+
'total_orders': 4,
204+
'orders': [
205+
{ 'orderdate': datetime.datetime(2020, 1, 13, 9, 32, 7), 'value': 99 },
206+
{ 'orderdate': datetime.datetime(2020, 5, 30, 8, 35, 52), 'value': 231 },
207+
{ 'orderdate': datetime.datetime(2020, 10, 3, 13, 49, 44), 'value': 102 },
208+
{ 'orderdate': datetime.datetime(2020, 12, 26, 8, 55, 46), 'value': 4 }
209209
],
210-
customer_id: '[email protected]'
210+
'customer_id': '[email protected]'
211211
}
212212
{
213-
first_purchase_date: 2020-08-18T23:04:48.000Z,
214-
total_value: 191,
215-
total_orders: 2,
216-
orders: [
217-
{ orderdate: 2020-08-18T23:04:48.000Z, value: 4 },
218-
{ orderdate: 2020-11-23T22:56:53.000Z, value: 187 }
213+
'first_purchase_date': datetime.datetime(2020, 8, 18, 23, 4, 48),
214+
'total_value': 191,
215+
'total_orders': 2,
216+
'orders': [
217+
{ 'orderdate': datetime.datetime(2020, 8, 18, 23, 4, 48), 'value': 4 },
218+
{ 'orderdate': datetime.datetime(2020, 11, 23, 22, 56, 53), 'value': 187 }
219219
],
220-
customer_id: '[email protected]'
220+
'customer_id': '[email protected]'
221221
}
222-
222+
223223
The result documents contain details from all the orders from
224224
a given customer, grouped by the customer's email address.
225225

source/aggregation/aggregation-tutorials/multi-field-join.txt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -219,35 +219,35 @@ Tutorial
219219
:copyable: false
220220

221221
{
222-
name: 'Asus Laptop',
223-
variation: 'Standard Display',
224-
category: 'ELECTRONICS',
225-
orders: [
222+
'name': 'Asus Laptop',
223+
'variation': 'Standard Display',
224+
'category': 'ELECTRONICS',
225+
'orders': [
226226
{
227-
customer_id: '[email protected]',
228-
orderdate: 2020-05-30T08:35:52.000Z,
229-
value: 431.43
227+
'customer_id': '[email protected]',
228+
'orderdate': datetime.datetime(2020, 5, 30, 8, 35, 52),
229+
'value': 431.43
230230
},
231231
{
232-
customer_id: '[email protected]',
233-
orderdate: 2020-12-26T08:55:46.000Z,
234-
value: 429.65
232+
'customer_id': '[email protected]',
233+
'orderdate': datetime.datetime(2020, 12, 26, 8, 55, 46),
234+
'value': 429.65
235235
}
236236
]
237237
}
238238
{
239-
name: 'Morphy Richards Food Mixer',
240-
variation: 'Deluxe',
241-
category: 'KITCHENWARE',
242-
orders: [
239+
'name': 'Morphy Richards Food Mixer',
240+
'variation': 'Deluxe',
241+
'category': 'KITCHENWARE',
242+
'orders': [
243243
{
244-
customer_id: '[email protected]',
245-
orderdate: 2020-01-01T08:25:37.000Z,
246-
value: 63.13
244+
'customer_id': '[email protected]',
245+
'orderdate': datetime.datetime(2020, 1, 1, 8, 25, 37),
246+
'value': 63.13
247247
}
248248
]
249249
}
250-
250+
251251
The result documents contain details from documents in the
252252
``orders`` collection and the ``products`` collection, joined by
253253
the product names and variations.

source/aggregation/aggregation-tutorials/one-to-one-join.txt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -197,27 +197,27 @@ Tutorial
197197
:copyable: false
198198

199199
{
200-
customer_id: '[email protected]',
201-
orderdate: 2020-05-30T08:35:52.000Z,
202-
value: 431.43,
203-
product_name: 'Asus Laptop',
204-
product_category: 'ELECTRONICS'
200+
'customer_id': '[email protected]',
201+
'orderdate': datetime.datetime(2020, 5, 30, 8, 35, 52),
202+
'value': 431.43,
203+
'product_name': 'Asus Laptop',
204+
'product_category': 'ELECTRONICS'
205205
}
206206
{
207-
customer_id: '[email protected]',
208-
orderdate: 2020-01-01T08:25:37.000Z,
209-
value: 63.13,
210-
product_name: 'Morphy Richardds Food Mixer',
211-
product_category: 'KITCHENWARE'
207+
'customer_id': '[email protected]',
208+
'orderdate': datetime.datetime(2020, 1, 1, 8, 25, 37),
209+
'value': 63.13,
210+
'product_name': 'Morphy Richardds Food Mixer',
211+
'product_category': 'KITCHENWARE'
212212
}
213213
{
214-
customer_id: '[email protected]',
215-
orderdate: 2020-12-26T08:55:46.000Z,
216-
value: 429.65,
217-
product_name: 'Asus Laptop',
218-
product_category: 'ELECTRONICS'
214+
'customer_id': '[email protected]',
215+
'orderdate': datetime.datetime(2020, 12, 26, 8, 55, 46),
216+
'value': 429.65,
217+
'product_name': 'Asus Laptop',
218+
'product_category': 'ELECTRONICS'
219219
}
220-
220+
221221
The result consists of documents that contain fields from
222222
documents in the ``orders`` collection and the ``products``
223223
collection, joined by matching the ``product_id`` field present in

source/aggregation/aggregation-tutorials/unpack-arrays.txt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -177,28 +177,28 @@ Tutorial
177177
:copyable: false
178178

179179
{
180-
product: 'Asus Laptop',
181-
total_value: 860,
182-
quantity: 2,
183-
product_id: 'abc12345'
180+
'product': 'Asus Laptop',
181+
'total_value': 860,
182+
'quantity': 2,
183+
'product_id': 'abc12345'
184184
}
185185
{
186-
product: 'Morphy Richards Food Mixer',
187-
total_value: 431,
188-
quantity: 1,
189-
product_id: 'pqr88223'
186+
'product': 'Morphy Richards Food Mixer',
187+
'total_value': 431,
188+
'quantity': 1,
189+
'product_id': 'pqr88223'
190190
}
191191
{
192-
product: 'Russell Hobbs Chrome Kettle',
193-
total_value: 16,
194-
quantity: 1,
195-
product_id: 'xyz11228'
192+
'product': 'Russell Hobbs Chrome Kettle',
193+
'total_value': 16,
194+
'quantity': 1,
195+
'product_id': 'xyz11228'
196196
}
197197
{
198-
product: 'Karcher Hose Set',
199-
total_value: 66,
200-
quantity: 3,
201-
product_id: 'def45678'
198+
'product': 'Karcher Hose Set',
199+
'total_value': 66,
200+
'quantity': 3,
201+
'product_id': 'def45678'
202202
}
203203

204204
The result documents contain details about the total value and

0 commit comments

Comments
 (0)