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 @@ -52,14 +52,19 @@ Behavior
52
52
Example
53
53
-------
54
54
55
- A collection named ``samples`` contains the following documents:
55
+ Create a collection named ``samples`` with the following documents:
56
56
57
57
.. code-block:: javascript
58
58
59
- { _id: 1, value: 9.25 }
60
- { _id: 2, value: 8.73 }
61
- { _id: 3, value: 4.32 }
62
- { _id: 4, value: -5.34 }
59
+ db.samples.insertMany(
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 }
65
+ ]
66
+ )
67
+
63
68
64
69
The following example returns both the original value and the ceiling
65
70
value:
Original file line number Diff line number Diff line change @@ -52,14 +52,18 @@ Behavior
52
52
Example
53
53
-------
54
54
55
- A collection named ``samples`` contains the following documents:
55
+ Create a collection named ``samples`` with the following documents:
56
56
57
57
.. code-block:: javascript
58
58
59
- { _id: 1, value: 9.25 }
60
- { _id: 2, value: 8.73 }
61
- { _id: 3, value: 4.32 }
62
- { _id: 4, value: -5.34 }
59
+ db.samples.insertMany(
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 }
65
+ ]
66
+ )
63
67
64
68
The following example returns both the original value and the floor
65
69
value:
Original file line number Diff line number Diff line change @@ -59,13 +59,18 @@ Behavior
59
59
Example
60
60
-------
61
61
62
- A collection ``samples`` contains the following documents:
62
+ Create a collection named ``samples`` with the following documents:
63
63
64
64
.. code-block:: javascript
65
65
66
- { _id: 1, H3O: 0.0025 }
67
- { _id: 2, H3O: 0.001 }
68
- { _id: 3, H3O: 0.02 }
66
+ db.samples.insertMany(
67
+ [
68
+ { _id: 1, H3O: 0.0025 },
69
+ { _id: 2, H3O: 0.001 },
70
+ { _id: 3, H3O: 0.02 }
71
+ ]
72
+ )
73
+
69
74
70
75
The following example calculates the pH value of the samples:
71
76
Original file line number Diff line number Diff line change @@ -164,14 +164,19 @@ the value as an integer.
164
164
Example
165
165
-------
166
166
167
- A collection named ``samples`` contains the following documents:
167
+ Create a collection named ``samples`` with the following documents:
168
168
169
169
.. code-block:: javascript
170
170
171
- { _id: 1, value: 19.25 }
172
- { _id: 2, value: 28.73 }
173
- { _id: 3, value: 34.32 }
174
- { _id: 4, value: -45.39 }
171
+ db.samples.insertMany(
172
+ [
173
+ { _id: 1, value: 19.25 },
174
+ { _id: 2, value: 28.73 },
175
+ { _id: 3, value: 34.32 },
176
+ { _id: 4, value: -45.39 }
177
+ ]
178
+ )
179
+
175
180
176
181
- The following aggregation returns ``value`` rounded to the
177
182
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