Skip to content

Commit aa69bf6

Browse files
authored
DOCSP-24256 adding insert operation to food examples (#1639)
* DOCSP-24256 adding insert operation to examples * DOCSP-24256 editing intro to example
1 parent e029849 commit aa69bf6

File tree

4 files changed

+56
-36
lines changed

4 files changed

+56
-36
lines changed

source/reference/operator/aggregation/strLenBytes.txt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,23 @@ Example
110110
Single-Byte and Multibyte Character Set
111111
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
112112

113-
A collection named ``food`` contains the following documents:
113+
Create a ``food`` collection with the following documents:
114114

115115
.. code-block:: javascript
116116

117-
{ "_id" : 1, "name" : "apple" }
118-
{ "_id" : 2, "name" : "banana" }
119-
{ "_id" : 3, "name" : "éclair" }
120-
{ "_id" : 4, "name" : "hamburger" }
121-
{ "_id" : 5, "name" : "jalapeño" }
122-
{ "_id" : 6, "name" : "pizza" }
123-
{ "_id" : 7, "name" : "tacos" }
124-
{ "_id" : 8, "name" : "寿司" }
117+
db.food.insertMany(
118+
[
119+
{ "_id" : 1, "name" : "apple" },
120+
{ "_id" : 2, "name" : "banana" },
121+
{ "_id" : 3, "name" : "éclair" },
122+
{ "_id" : 4, "name" : "hamburger" },
123+
{ "_id" : 5, "name" : "jalapeño" },
124+
{ "_id" : 6, "name" : "pizza" },
125+
{ "_id" : 7, "name" : "tacos" },
126+
{ "_id" : 8, "name" : "寿司" }
127+
]
128+
)
129+
125130

126131
The following operation uses the ``$strLenBytes`` operator to calculate
127132
the ``length`` of each ``name`` value:

source/reference/operator/aggregation/strLenCP.txt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,23 @@ Example
7373
Single-Byte and Multibyte Character Set
7474
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7575

76-
A collection named ``food`` contains the following documents:
76+
Create a ``food`` collection with the following documents:
7777

7878
.. code-block:: javascript
7979

80-
{ "_id" : 1, "name" : "apple" }
81-
{ "_id" : 2, "name" : "banana" }
82-
{ "_id" : 3, "name" : "éclair" }
83-
{ "_id" : 4, "name" : "hamburger" }
84-
{ "_id" : 5, "name" : "jalapeño" }
85-
{ "_id" : 6, "name" : "pizza" }
86-
{ "_id" : 7, "name" : "tacos" }
87-
{ "_id" : 8, "name" : "寿司" }
80+
db.food.insertMany(
81+
[
82+
{ "_id" : 1, "name" : "apple" },
83+
{ "_id" : 2, "name" : "banana" },
84+
{ "_id" : 3, "name" : "éclair" },
85+
{ "_id" : 4, "name" : "hamburger" },
86+
{ "_id" : 5, "name" : "jalapeño" },
87+
{ "_id" : 6, "name" : "pizza" },
88+
{ "_id" : 7, "name" : "tacos" },
89+
{ "_id" : 8, "name" : "寿司" }
90+
]
91+
)
92+
8893

8994
The following operation uses the ``$strLenCP`` operator to calculate
9095
the ``length`` of each ``name`` value:

source/reference/operator/aggregation/substrBytes.txt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,18 +212,23 @@ The operation returns the following results:
212212
Single-Byte and Multibyte Character Set
213213
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
214214

215-
A collection named ``food`` contains the following documents:
215+
Create a ``food`` collection with the following documents:
216216

217217
.. code-block:: javascript
218218

219-
{ "_id" : 1, "name" : "apple" }
220-
{ "_id" : 2, "name" : "banana" }
221-
{ "_id" : 3, "name" : "éclair" }
222-
{ "_id" : 4, "name" : "hamburger" }
223-
{ "_id" : 5, "name" : "jalapeño" }
224-
{ "_id" : 6, "name" : "pizza" }
225-
{ "_id" : 7, "name" : "tacos" }
226-
{ "_id" : 8, "name" : "寿司sushi" }
219+
db.food.insertMany(
220+
[
221+
{ "_id" : 1, "name" : "apple" },
222+
{ "_id" : 2, "name" : "banana" },
223+
{ "_id" : 3, "name" : "éclair" },
224+
{ "_id" : 4, "name" : "hamburger" },
225+
{ "_id" : 5, "name" : "jalapeño" },
226+
{ "_id" : 6, "name" : "pizza" },
227+
{ "_id" : 7, "name" : "tacos" },
228+
{ "_id" : 8, "name" : "寿司sushi" }
229+
]
230+
)
231+
227232

228233
The following operation uses the ``$substrBytes`` operator to create a three
229234
byte ``menuCode`` from the ``name`` value:

source/reference/operator/aggregation/substrCP.txt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,23 @@ The operation returns the following results:
157157
Single-Byte and Multibyte Character Set
158158
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
159159

160-
A collection named ``food`` contains the following documents:
160+
Create a ``food`` collection with the following documents:
161161

162162
.. code-block:: javascript
163163

164-
{ "_id" : 1, "name" : "apple" }
165-
{ "_id" : 2, "name" : "banana" }
166-
{ "_id" : 3, "name" : "éclair" }
167-
{ "_id" : 4, "name" : "hamburger" }
168-
{ "_id" : 5, "name" : "jalapeño" }
169-
{ "_id" : 6, "name" : "pizza" }
170-
{ "_id" : 7, "name" : "tacos" }
171-
{ "_id" : 8, "name" : "寿司sushi" }
164+
db.food.insertMany(
165+
[
166+
{ "_id" : 1, "name" : "apple" },
167+
{ "_id" : 2, "name" : "banana" },
168+
{ "_id" : 3, "name" : "éclair" },
169+
{ "_id" : 4, "name" : "hamburger" },
170+
{ "_id" : 5, "name" : "jalapeño" },
171+
{ "_id" : 6, "name" : "pizza" },
172+
{ "_id" : 7, "name" : "tacos" },
173+
{ "_id" : 8, "name" : "寿司sushi" }
174+
]
175+
)
176+
172177

173178
The following example uses the ``$substrCP`` operator to create a three
174179
byte ``menuCode`` from the ``name`` value:

0 commit comments

Comments
 (0)