Skip to content

Commit 6605782

Browse files
authored
(DOCSP-8699) Add $not example to Query Your Data page (#222)
* (DOCSP-8699) Add example to Query Your Data page * Simplifying language * Changes from copy review
1 parent 3fe1fd8 commit 6605782

File tree

1 file changed

+106
-33
lines changed

1 file changed

+106
-33
lines changed

source/query/filter.txt

Lines changed: 106 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,19 @@ Examples
122122

123123
[
124124
{
125-
"_id":{"$oid":"5a9427648b0beebeb69579cc"},
126125
"name":"Andrea Le",
127126
"email":"[email protected]",
128127
"version":5,
129128
"scores":[85, 95, 75],
130129
"dateCreated":{"$date":"2003-03-26"}
131130
},
132131
{
133-
"_id":{"$oid":"5a9427648b0beebeb69579cf"},
132+
"email":"[email protected]",
133+
"version":4,
134+
"scores":[90, 90, 70],
135+
"dateCreated":{"$date":"2001-04-15"}
136+
},
137+
{
134138
"name":"Greg Powell",
135139
"email":"[email protected]",
136140
"version":1,
@@ -166,29 +170,74 @@ Examples
166170
.. tab:: Filter for a Match
167171
:tabid: match
168172

169-
The following :ref:`query filter <query-bar-filter>` uses the
170-
:manual:`$eq operator </reference/operator/query/eq/>` to find
171-
all documents where ``name`` is "Andrea Le" .
173+
The following :ref:`query filter <query-bar-filter>` finds
174+
all documents where the value of ``name`` is "Andrea Le".
172175

173176
.. code-block:: shell
174177

175-
{ name: { $eq: "Andrea Le" } }
178+
{ name: "Andrea Le" }
176179

177180
The query returns the following document because the ``name``
178-
field value in the document is an exact match.
181+
field value is an exact match.
179182

180183
.. code-block:: JSON
181184
:copyable: false
182185

183186
{
184-
"_id":ObjectId("5a9427648b0beebeb69579cc"),
187+
"_id": {"$oid": "5e349915cebae490877d561d"},
185188
"name":"Andrea Le",
186189
"email":"[email protected]",
187190
"version":5,
188191
"scores":[85, 95, 75],
189-
"dateCreated":2003-03-26T00:00:00.000+00:00
192+
"dateCreated":{"$date":"2003-03-26"}
190193
}
191194

195+
.. tab:: Filter by Exclusion ($not)
196+
:tabid: not
197+
198+
The following :ref:`query filter <query-bar-filter>` uses the
199+
:manual:`$not operator </reference/operator/query/not/>` to find
200+
all documents where:
201+
202+
- The value of the ``name`` field is **not** equal to "Andrea Le",
203+
or
204+
205+
- The ``name`` field does not exist
206+
207+
.. code-block:: shell
208+
209+
{ name: { $not: { $eq: "Andrea Le" } } }
210+
211+
The query returns the following documents because the ``name``
212+
field either does not exist or its value is something other than
213+
"Andrea Le".
214+
215+
.. code-block:: JSON
216+
:copyable: false
217+
218+
[
219+
{
220+
"_id":{"$oid":"5e349915cebae490877d561e"},
221+
"email":"[email protected]",
222+
"version":4,
223+
"scores":[90, 90, 75],
224+
"dateCreated":{"$date":"2001-04-15"}
225+
},
226+
{
227+
"_id":{"$oid":"5a9427648b0beebeb69579cf"},
228+
"name":"Greg Powell",
229+
"email":"[email protected]",
230+
"version":1,
231+
"scores":[65, 75, 80],
232+
"dateCreated":{"$date":"1999-02-10"}
233+
}
234+
]
235+
236+
.. seealso::
237+
238+
For a complete list of logical query operators, see
239+
:manual:`Logical Query Operators</reference/operator/query-logical/>`.
240+
192241
.. tab:: Filter by Comparison
193242
:tabid: compare
194243

@@ -201,20 +250,34 @@ Examples
201250

202251
{ version: { $lte: 4 } }
203252

204-
The query returns the following document because the value of
205-
the ``version`` field in the document is less than ``4``.
253+
The query returns the following documents because
254+
the ``version`` field values are less than or equal to ``4``.
206255

207256
.. code-block:: JSON
208257
:copyable: false
209258

210-
{
211-
"_id":ObjectId("5a9427648b0beebeb69579cf"),
212-
"name":"Greg Powell",
213-
"email":"[email protected]",
214-
"version":1,
215-
"scores":[65, 75, 80],
216-
"dateCreated":1999-02-10T00:00:00.000+00:00
217-
}
259+
[
260+
{
261+
"_id":{"$oid":"5e349915cebae490877d561e"},
262+
"email":"[email protected]",
263+
"version":4,
264+
"scores":[90, 90, 75],
265+
"dateCreated":{"$date":"2001-04-15"}
266+
},
267+
{
268+
"_id":{"$oid":"5a9427648b0beebeb69579cf"},
269+
"name":"Greg Powell",
270+
"email":"[email protected]",
271+
"version":1,
272+
"scores":[65, 75, 80],
273+
"dateCreated":{"$date":"1999-02-10"}
274+
}
275+
]
276+
277+
.. seealso::
278+
279+
For a complete list of comparison operators, see
280+
:manual:`Comparison Query Operators </reference/operator/query-comparison/>`.
218281

219282
.. tab:: Filter by Date
220283
:tabid: date
@@ -229,22 +292,32 @@ Examples
229292

230293
{ dateCreated: { $gt: Date('2000-06-22') } }
231294

232-
The query returns the following document because the value of
233-
the ``dateCreated`` field is after June 22, 2000.
295+
The query returns the following documents because
296+
the ``dateCreated`` field values are after June 22, 2000.
234297

235298
.. code-block:: JSON
236299
:copyable: false
237300

238-
{
239-
"_id":ObjectId("5a9427648b0beebeb69579cc"),
240-
"name":"Andrea Le",
241-
"email":"[email protected]",
242-
"version":1,
243-
"scores":[85, 95, 75],
244-
"dateCreated":2003-03-26T00:00:00.000+00:00
245-
}
301+
[
302+
{
303+
"_id": {"$oid": "5e349915cebae490877d561d"},
304+
"name":"Andrea Le",
305+
"email":"[email protected]",
306+
"version":5,
307+
"scores":[85, 95, 75],
308+
"dateCreated":{"$date":"2003-03-26"}
309+
},
310+
{
311+
"_id":{"$oid":"5e349915cebae490877d561e"},
312+
"email":"[email protected]",
313+
"version":4,
314+
"scores":[90, 90, 75],
315+
"dateCreated":{"$date":"2001-04-15"}
316+
}
317+
]
318+
246319

247-
.. tab:: Filter by Elements in an Array
320+
.. tab:: Filter by Array Elements
248321
:tabid: array
249322

250323
The following :ref:`query filter <query-bar-filter>` uses the
@@ -263,12 +336,12 @@ Examples
263336
:copyable: false
264337

265338
{
266-
"_id":ObjectId("5a9427648b0beebeb69579cc"),
339+
"_id": {"$oid": "5e349915cebae490877d561d"},
267340
"name":"Andrea Le",
268341
"email":"[email protected]",
269-
"version":1,
342+
"version":5,
270343
"scores":[85, 95, 75],
271-
"dateCreated":2003-03-26T00:00:00.000+00:00
344+
"dateCreated":{"$date":"2003-03-26"}
272345
}
273346

274347
For more query examples, see

0 commit comments

Comments
 (0)