@@ -12,11 +12,11 @@ async function loadData() {
1212 await client . connect ( ) ;
1313
1414 const database = client . db ( "test" ) ;
15- const collection = database . collection ( "pizza" ) ;
15+ const pizza = database . collection ( "pizza" ) ;
1616
17- await collection . drop ( ) ;
17+ await pizza . drop ( ) ;
1818
19- await collection . insertMany ( [
19+ await pizza . insertMany ( [
2020 {
2121 name : "Steve Lobsters" ,
2222 address : "731 Yexington Avenue" ,
@@ -64,9 +64,9 @@ async function loadData() {
6464 } ,
6565 ]
6666 }
67- ) ;
67+ ] ) ;
6868
69- console . log ( JSON . stringify ( await ( await collection . find ( ) ) . toArray ( ) ) ) ;
69+ console . log ( JSON . stringify ( await ( await pizza . find ( ) ) . toArray ( ) ) ) ;
7070 } finally {
7171 await client . close ( ) ;
7272 }
@@ -79,19 +79,19 @@ async function runAllArrayElements() {
7979 await client . connect ( ) ;
8080
8181 const database = client . db ( "test" ) ;
82- const collection = database . collection ( "pizza" ) ;
82+ const pizza = database . collection ( "pizza" ) ;
8383
84- console . log ( JSON . stringify ( await ( await collection . find ( ) ) . toArray ( ) ) ) ;
84+ console . log ( JSON . stringify ( await ( await pizza . find ( ) ) . toArray ( ) ) ) ;
8585
8686 // start allArrayElement example
8787 const query = { "name" : "Popeye" } ;
8888 const updateDocument = {
8989 $push : { "items.$[].toppings" : "fresh mozzarella" }
9090 } ;
91- const result = await collection . updateOne ( query , updateDocument ) ;
91+ const result = await pizza . updateOne ( query , updateDocument ) ;
9292 // end allArrayElement example
9393 console . log ( result . modifiedCount ) ;
94- console . log ( JSON . stringify ( await ( await collection . find ( ) ) . toArray ( ) ) ) ;
94+ console . log ( JSON . stringify ( await ( await pizza . find ( ) ) . toArray ( ) ) ) ;
9595 } finally {
9696 await client . close ( ) ;
9797 }
@@ -102,19 +102,19 @@ async function runFirstArrayElement() {
102102 await client . connect ( ) ;
103103
104104 const database = client . db ( "test" ) ;
105- const collection = database . collection ( "pizza" ) ;
105+ const pizza = database . collection ( "pizza" ) ;
106106
107- console . log ( JSON . stringify ( await ( await collection . find ( ) ) . toArray ( ) ) ) ;
107+ console . log ( JSON . stringify ( await ( await pizza . find ( ) ) . toArray ( ) ) ) ;
108108
109109 // start firstArrayElement example
110110 const query = { name : "Steve Lobsters" , "items.type" : "pizza" } ;
111111 const updateDocument = {
112112 $set : { "items.$.size" : "extra large" }
113113 } ;
114- const result = await collection . updateOne ( query , updateDocument ) ;
114+ const result = await pizza . updateOne ( query , updateDocument ) ;
115115 // end firstArrayElement example
116116 console . log ( result . modifiedCount ) ;
117- console . log ( JSON . stringify ( await ( await collection . find ( ) ) . toArray ( ) ) ) ;
117+ console . log ( JSON . stringify ( await ( await pizza . find ( ) ) . toArray ( ) ) ) ;
118118 } finally {
119119 await client . close ( ) ;
120120 }
@@ -126,9 +126,9 @@ async function arrayFiltersOne() {
126126 await client . connect ( ) ;
127127
128128 const database = client . db ( "test" ) ;
129- const collection = database . collection ( "pizza" ) ;
129+ const pizza = database . collection ( "pizza" ) ;
130130
131- console . log ( JSON . stringify ( await ( await collection . find ( ) ) . toArray ( ) ) ) ;
131+ console . log ( JSON . stringify ( await ( await pizza . find ( ) ) . toArray ( ) ) ) ;
132132
133133 // start arrayFiltersOne example
134134 const query = { name : "Steve Lobsters" } ;
@@ -142,11 +142,11 @@ async function arrayFiltersOne() {
142142 } ]
143143 } ;
144144
145- const result = await collection . updateMany ( query , updateDocument , options ) ;
145+ const result = await pizza . updateMany ( query , updateDocument , options ) ;
146146 // end arrayFiltersOne example
147147
148148 console . log ( result . modifiedCount ) ;
149- console . log ( JSON . stringify ( await ( await collection . find ( ) ) . toArray ( ) ) ) ;
149+ console . log ( JSON . stringify ( await ( await pizza . find ( ) ) . toArray ( ) ) ) ;
150150 } finally {
151151 await client . close ( ) ;
152152 }
@@ -157,9 +157,9 @@ async function arrayFiltersTwo() {
157157 await client . connect ( ) ;
158158
159159 const database = client . db ( "test" ) ;
160- const collection = database . collection ( "pizza" ) ;
160+ const pizza = database . collection ( "pizza" ) ;
161161
162- console . log ( JSON . stringify ( await ( await collection . find ( ) ) . toArray ( ) ) ) ;
162+ console . log ( JSON . stringify ( await ( await pizza . find ( ) ) . toArray ( ) ) ) ;
163163
164164 // start arrayFiltersTwo example
165165 const query = { name : "Steve Lobsters" } ;
@@ -174,11 +174,11 @@ async function arrayFiltersTwo() {
174174 } ,
175175 ] ,
176176 } ;
177- const result = await collection . updateOne ( query , updateDocument , options ) ;
177+ const result = await pizza . updateOne ( query , updateDocument , options ) ;
178178 // end arrayFiltersTwo example
179179 console . log ( result . modifiedCount ) ;
180180
181- collection . insertOne ( {
181+ pizza . insertOne ( {
182182 name : "Steve Lobsters" ,
183183 address : "731 Yexington Avenue" ,
184184 items : [
@@ -211,7 +211,7 @@ async function arrayFiltersTwo() {
211211 ] ,
212212 } ) ;
213213
214- console . log ( JSON . stringify ( await ( await collection . find ( ) ) . toArray ( ) ) ) ;
214+ console . log ( JSON . stringify ( await ( await pizza . find ( ) ) . toArray ( ) ) ) ;
215215 } finally {
216216 await client . close ( ) ;
217217 }
0 commit comments