@@ -79,15 +79,17 @@ evaluation after encountering the first ``false`` expression.
79
79
Example
80
80
-------
81
81
82
- Consider an ``inventory`` collection with the following documents:
82
+ Create an example ``inventory`` collection with the following documents:
83
83
84
84
.. code-block:: javascript
85
85
86
- { "_id" : 1, "item" : "abc1", description: "product 1", qty: 300 }
87
- { "_id" : 2, "item" : "abc2", description: "product 2", qty: 200 }
88
- { "_id" : 3, "item" : "xyz1", description: "product 3", qty: 250 }
89
- { "_id" : 4, "item" : "VWZ1", description: "product 4", qty: 300 }
90
- { "_id" : 5, "item" : "VWZ2", description: "product 5", qty: 180 }
86
+ db.inventory.insertMany([
87
+ { "_id" : 1, "item" : "abc1", description: "product 1", qty: 300 },
88
+ { "_id" : 2, "item" : "abc2", description: "product 2", qty: 200 },
89
+ { "_id" : 3, "item" : "xyz1", description: "product 3", qty: 250 },
90
+ { "_id" : 4, "item" : "VWZ1", description: "product 4", qty: 300 },
91
+ { "_id" : 5, "item" : "VWZ2", description: "product 5", qty: 180 }
92
+ ])
91
93
92
94
The following operation uses the :expression:`$and` operator to
93
95
determine if ``qty`` is greater than 100 *and* less than ``250``:
@@ -111,8 +113,8 @@ The operation returns the following results:
111
113
112
114
.. code-block:: javascript
113
115
114
- { "_id" : 1, "item" : "abc1", "result" : false }
115
- { "_id" : 2, "item" : "abc2", "result" : true }
116
- { "_id" : 3, "item" : "xyz1", "result" : false }
117
- { "_id" : 4, "item" : "VWZ1", "result" : false }
118
- { "_id" : 5, "item" : "VWZ2", "result" : true }
116
+ { "_id" : 1, "item" : "abc1", "qty" : 300, " result" : false }
117
+ { "_id" : 2, "item" : "abc2", "qty" : 200, " result" : true }
118
+ { "_id" : 3, "item" : "xyz1", "qty" : 250, " result" : false }
119
+ { "_id" : 4, "item" : "VWZ1", "qty" : 300, " result" : false }
120
+ { "_id" : 5, "item" : "VWZ2", "qty" : 180, " result" : true }
0 commit comments