Skip to content

Commit cc4d800

Browse files
Clarifying filter example
1 parent 50f4c68 commit cc4d800

File tree

1 file changed

+41
-42
lines changed

1 file changed

+41
-42
lines changed

Diff for: source/query/filter.txt

+41-42
Original file line numberDiff line numberDiff line change
@@ -20,57 +20,56 @@ querying documents, see :manual:`Query Documents
2020
Set Query Filter
2121
----------------
2222

23-
#. In the :guilabel:`Filter` field, enter a filter document.
23+
#. In the :guilabel:`Filter` field, enter a filter document. You can use
24+
all of the MongoDB :manual:`query operators
25+
</reference/operator/query/>` except the :query:`$text` and
26+
:query:`$expr` operators.
2427

25-
You can use all of the MongoDB
26-
:manual:`query operators </reference/operator/query/>` except
27-
the :query:`$text` and :query:`$expr` operators.
28-
29-
.. tip::
28+
.. example::
3029

31-
In the :doc:`Schema </schema>` tab, you can also use the
32-
:ref:`build-query` to enter a query into the query bar.
30+
The following filter only returns documents which have a ``Country``
31+
value of ``Brazil``:
32+
33+
.. code-block:: json
34+
35+
{ Country: "Brazil" }
3336

34-
As you type, the :guilabel:`Find` button is disabled and the
35-
:guilabel:`Filter` label turns red until a valid query is entered.
37+
#. .. include:: /includes/run-query.rst
3638

37-
.. figure:: /images/querybar/query-filter-error.png
39+
.. figure:: /images/querybar/query-filter-success.png
3840
:figwidth: 600px
3941
:lightbox:
4042

41-
The Compass :guilabel:`Filter` supports using the
42-
:binary:`~bin.mongo` shell mode representation of the MongoDB
43-
Extended JSON :manual:`BSON data types </reference/mongodb-extended-json#bson-data-types-and-associated-representations>`.
43+
.. note::
4444

45-
.. example::
46-
47-
The following filter returns documents where
48-
``start_date`` is greater than than the BSON ``Date``
49-
``2017-05-01``:
45+
.. include:: /includes/extracts/query-bar-results.rst
5046

51-
.. code-block:: javascript
47+
Supported Data Types in the Query Bar
48+
-------------------------------------
5249

53-
{ "start_date": {$gt: new Date('2017-05-01')} }
50+
The Compass :guilabel:`Filter` supports using the
51+
:binary:`~bin.mongo` shell mode representation of the MongoDB
52+
Extended JSON :manual:`BSON data types </reference/mongodb-extended-json#bson-data-types-and-associated-representations>`.
5453

55-
By specifying the ``Date`` type in both ``start_date`` and the
56-
``$gt`` comparison operator, Compass performs the ``greater
57-
than`` comparison chronologically, returning documents with
58-
``start_date`` later than ``2017-05-01``.
54+
.. example::
5955

60-
Without the ``Date`` type specification, Compass compares the
61-
``start_dates`` as strings
62-
`lexicographically <https://en.wikipedia.org/wiki/Lexicographical_order>`_,
63-
instead of comparing the values chronologically.
56+
The following filter returns documents where
57+
``start_date`` is greater than than the BSON ``Date``
58+
``2017-05-01``:
6459

65-
#. .. include:: /includes/run-query.rst
60+
.. code-block:: javascript
6661

67-
.. figure:: /images/querybar/query-filter-success.png
68-
:figwidth: 600px
69-
:lightbox:
62+
{ "start_date": {$gt: new Date('2017-05-01')} }
7063

71-
.. note::
64+
By specifying the ``Date`` type in both ``start_date`` and the
65+
``$gt`` comparison operator, Compass performs the ``greater
66+
than`` comparison chronologically, returning documents with
67+
``start_date`` later than ``2017-05-01``.
7268

73-
.. include:: /includes/extracts/query-bar-results.rst
69+
Without the ``Date`` type specification, Compass compares the
70+
``start_dates`` as strings
71+
`lexicographically <https://en.wikipedia.org/wiki/Lexicographical_order>`_,
72+
instead of comparing the values chronologically.
7473

7574

7675
Clear the Query
@@ -89,11 +88,10 @@ How Does the Compass Query Compare to MongoDB and SQL Queries?
8988
You have 3,235 articles. You would like to see all articles
9089
that Joe Bloggs wrote.
9190

92-
SQL
93-
.. code-block:: sql
91+
Compass Filter Option
92+
.. code-block:: javascript
9493

95-
SELECT * FROM article
96-
WHERE author = "Joe Bloggs";
94+
{ author : { $eq : "Joe Bloggs" } }
9795

9896
MongoDB Aggregation
9997
.. code-block:: javascript
@@ -102,7 +100,8 @@ How Does the Compass Query Compare to MongoDB and SQL Queries?
102100
{ $filter : { author : { $eq : "Joe Bloggs" } } }
103101
);
104102

105-
Compass Filter Option
106-
.. code-block:: javascript
103+
SQL
104+
.. code-block:: sql
107105

108-
{ author : { $eq : "Joe Bloggs" } }
106+
SELECT * FROM article
107+
WHERE author = "Joe Bloggs";

0 commit comments

Comments
 (0)