File tree Expand file tree Collapse file tree 5 files changed +48
-25
lines changed
source/reference/operator/aggregation Expand file tree Collapse file tree 5 files changed +48
-25
lines changed Original file line number Diff line number Diff line change @@ -54,14 +54,19 @@ Behavior
54
54
Example
55
55
-------
56
56
57
- A collection named ``samples`` contains the following documents:
57
+ Create a collection named ``samples`` with the following documents:
58
58
59
59
.. code-block:: javascript
60
60
61
- { _id: 1, value: 9.25 }
62
- { _id: 2, value: 8.73 }
63
- { _id: 3, value: 4.32 }
64
- { _id: 4, value: -5.34 }
61
+ db.samples.insertMany(
62
+ [
63
+ { _id: 1, value: 9.25 },
64
+ { _id: 2, value: 8.73 },
65
+ { _id: 3, value: 4.32 },
66
+ { _id: 4, value: -5.34 }
67
+ ]
68
+ )
69
+
65
70
66
71
The following example returns both the original value and the ceiling
67
72
value:
Original file line number Diff line number Diff line change @@ -54,14 +54,18 @@ Behavior
54
54
Example
55
55
-------
56
56
57
- A collection named ``samples`` contains the following documents:
57
+ Create a collection named ``samples`` with the following documents:
58
58
59
59
.. code-block:: javascript
60
60
61
- { _id: 1, value: 9.25 }
62
- { _id: 2, value: 8.73 }
63
- { _id: 3, value: 4.32 }
64
- { _id: 4, value: -5.34 }
61
+ db.samples.insertMany(
62
+ [
63
+ { _id: 1, value: 9.25 },
64
+ { _id: 2, value: 8.73 },
65
+ { _id: 3, value: 4.32 },
66
+ { _id: 4, value: -5.34 }
67
+ ]
68
+ )
65
69
66
70
The following example returns both the original value and the floor
67
71
value:
Original file line number Diff line number Diff line change @@ -61,13 +61,18 @@ Behavior
61
61
Example
62
62
-------
63
63
64
- A collection ``samples`` contains the following documents:
64
+ Create a collection named ``samples`` with the following documents:
65
65
66
66
.. code-block:: javascript
67
67
68
- { _id: 1, H3O: 0.0025 }
69
- { _id: 2, H3O: 0.001 }
70
- { _id: 3, H3O: 0.02 }
68
+ db.samples.insertMany(
69
+ [
70
+ { _id: 1, H3O: 0.0025 },
71
+ { _id: 2, H3O: 0.001 },
72
+ { _id: 3, H3O: 0.02 }
73
+ ]
74
+ )
75
+
71
76
72
77
The following example calculates the pH value of the samples:
73
78
Original file line number Diff line number Diff line change @@ -195,14 +195,19 @@ the value as an integer.
195
195
Example
196
196
-------
197
197
198
- A collection named ``samples`` contains the following documents:
198
+ Create a collection named ``samples`` with the following documents:
199
199
200
200
.. code-block:: javascript
201
201
202
- { _id: 1, value: 19.25 }
203
- { _id: 2, value: 28.73 }
204
- { _id: 3, value: 34.32 }
205
- { _id: 4, value: -45.39 }
202
+ db.samples.insertMany(
203
+ [
204
+ { _id: 1, value: 19.25 },
205
+ { _id: 2, value: 28.73 },
206
+ { _id: 3, value: 34.32 },
207
+ { _id: 4, value: -45.39 }
208
+ ]
209
+ )
210
+
206
211
207
212
- The following aggregation returns ``value`` rounded to the
208
213
first decimal place:
Original file line number Diff line number Diff line change @@ -150,14 +150,18 @@ an integer.
150
150
Example
151
151
-------
152
152
153
- A collection named ``samples`` contains the following documents:
153
+ Create a collection named ``samples`` with the following documents:
154
154
155
155
.. code-block:: javascript
156
-
157
- { _id: 1, value: 19.25 }
158
- { _id: 2, value: 28.73 }
159
- { _id: 3, value: 34.32 }
160
- { _id: 4, value: -45.34 }
156
+
157
+ db.samples.insertMany(
158
+ [
159
+ { _id: 1, value: 19.25 },
160
+ { _id: 2, value: 28.73 },
161
+ { _id: 3, value: 34.32 },
162
+ { _id: 4, value: -45.34 }
163
+ ]
164
+ )
161
165
162
166
- The following aggregation returns ``value`` truncated to the first
163
167
decimal place:
You can’t perform that action at this time.
0 commit comments