Skip to content

Commit 89f170f

Browse files
authored
DOCSP-24256 adding insert operation to food examples (#1639) (#1660)
* DOCSP-24256 adding insert operation to examples * DOCSP-24256 editing intro to example
1 parent 155d54d commit 89f170f

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
@@ -112,18 +112,23 @@ Example
112112
Single-Byte and Multibyte Character Set
113113
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
114114

115-
A collection named ``food`` contains the following documents:
115+
Create a ``food`` collection with the following documents:
116116

117117
.. code-block:: javascript
118118

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

128133
The following operation uses the ``$strLenBytes`` operator to calculate
129134
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
@@ -75,18 +75,23 @@ Example
7575
Single-Byte and Multibyte Character Set
7676
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7777

78-
A collection named ``food`` contains the following documents:
78+
Create a ``food`` collection with the following documents:
7979

8080
.. code-block:: javascript
8181

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

9196
The following operation uses the ``$strLenCP`` operator to calculate
9297
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
@@ -214,18 +214,23 @@ The operation returns the following results:
214214
Single-Byte and Multibyte Character Set
215215
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
216216

217-
A collection named ``food`` contains the following documents:
217+
Create a ``food`` collection with the following documents:
218218

219219
.. code-block:: javascript
220220

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

230235
The following operation uses the ``$substrBytes`` operator to create a three
231236
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)