@@ -3,16 +3,19 @@ Operator Reference
3
3
==================
4
4
5
5
.. default-domain:: mongodb
6
- .. highlight:: javascript
7
6
8
7
This document contains a reference to all :term:`operators <operator>`
9
8
used with MongoDB in version |version|.
10
9
10
+ .. index:: query selectors
11
11
.. _query-selectors:
12
12
13
13
Query Selectors
14
14
---------------
15
15
16
+ .. index:: query selectors; comparison
17
+ .. _query-selectors-comparison:
18
+
16
19
Comparison
17
20
~~~~~~~~~~
18
21
@@ -94,6 +97,9 @@ This statement returns all documents with ``field`` between
94
97
95
98
{ field: [-1,3] }
96
99
100
+ .. index:: query selectors; document
101
+ .. _query-selectors-document:
102
+
97
103
Document
98
104
~~~~~~~~
99
105
@@ -203,6 +209,9 @@ Document
203
209
returns all documents in ``collection`` where the value of ``age``
204
210
is *not* 3, 5, or 7.
205
211
212
+
213
+ .. index:: query selectors; geospatial
214
+ .. _query-selectors-geospatial:
206
215
.. _geospatial-query-operators:
207
216
.. _geolocation-operators:
208
217
@@ -319,6 +328,9 @@ Geospatial
319
328
You cannot specify :operator:`$uniqueDocs` with :operator:`$near`
320
329
or haystack queries.
321
330
331
+ .. index:: query selectors; logical
332
+ .. _query-selectors-logical:
333
+
322
334
Logical
323
335
~~~~~~~
324
336
@@ -348,7 +360,7 @@ Logical
348
360
field that has the value ``19``, and *either* a ``key1`` field with
349
361
``value1`` *or* a ``key2`` field with ``value2``.
350
362
351
- .. versionadded: 2.0
363
+ .. versionadded:: 2.0
352
364
You may nest :operator:`$or` operations; however, these
353
365
expressions are not as efficiently optimized as top-level
354
366
:operator:`$or` operations.
@@ -422,6 +434,9 @@ Logical
422
434
423
435
.. see:: The :operator:`$type` operator, used in the above example.
424
436
437
+ .. index:: query selectors; element
438
+ .. _query-selectors-element:
439
+
425
440
Element
426
441
~~~~~~~
427
442
@@ -524,7 +539,6 @@ Element
524
539
- ``s`` allows the dot (e.g. ``.``) character to match all
525
540
characters *including* newline characters.
526
541
527
-
528
542
:option:`$regex` only provides the ``i` and ``m`` options in the
529
543
short JavaScript syntax (i.e. ``/acme.*corp/i``). To use ``x``
530
544
and ``s`` you must use the ":operator:`$regex`" operator with the
@@ -569,6 +583,9 @@ Element
569
583
570
584
db.collection.find( "field % d == m" );
571
585
586
+ .. index:: query selectors; javascript
587
+ .. _query-selectors-javascript:
588
+
572
589
JavaScript
573
590
~~~~~~~~~~
574
591
@@ -595,6 +612,9 @@ JavaScript
595
612
standard query operator to filter the result set. Using
596
613
:operator:`$where` alone requires a table scan.
597
614
615
+ .. index:: query selectors; array
616
+ .. _query-selectors-array:
617
+
598
618
Array
599
619
~~~~~
600
620
@@ -656,11 +676,20 @@ Array
656
676
657
677
{ array: [ { value1:1, value2:0 }, { value1:1, value2:2 } ] }
658
678
679
+ .. index:: operators; update
680
+ .. index:: update operators
659
681
.. _update-operators:
660
682
661
683
Update
662
684
------
663
685
686
+ .. index:: update operators; fields
687
+ .. _operators-update-fields:
688
+ .. _update-operators-fields:
689
+
690
+ Fields
691
+ ~~~~~~
692
+
664
693
.. operator:: $set
665
694
666
695
Use the :operator:`$set` operator to set a particular value. The
@@ -725,6 +754,32 @@ Update
725
754
726
755
:operator:`$inc` accepts positive and negative incremental amounts.
727
756
757
+ .. operator:: $rename
758
+
759
+ The :operator:`$rename` operator changes the name of a field. Consider the
760
+ following example:
761
+
762
+ .. code-block:: javascript
763
+
764
+ db.collection.update( { field: value }, { $rename: { old_field: new_field } } );
765
+
766
+ Here, the :operator:`$rename` operator changes the name of the ``old_field``
767
+ field to ``new_field``, in the document that matches the query ``{
768
+ field: value }`` in ``collection``.
769
+
770
+ The :operator:`$rename` operator will expand arrays and
771
+ sub-documents to find a match for field names (e.g. ``old_field``
772
+ in the example above.)
773
+
774
+ .. versionadded:: 1.7.2
775
+
776
+ .. index:: update operators; array
777
+ .. _operators-update-array:
778
+ .. _update-operators-array:
779
+
780
+ Array
781
+ ~~~~~
782
+
728
783
.. operator:: $push
729
784
730
785
The :operator:`$push` operator appends a specified value to an array. For
@@ -853,24 +908,12 @@ Update
853
908
the array in ``field1``, in the document that matches the
854
909
query statement ``{ field: value }`` in ``collection``.
855
910
856
- .. operator:: $rename
857
-
858
- The :operator:`$rename` operator changes the name of a field. Consider the
859
- following example:
911
+ .. index:: update operators; bitwise
912
+ .. _operators-update-bitwise:
913
+ .. _update-operators-bitwise:
860
914
861
- .. code-block:: javascript
862
-
863
- db.collection.update( { field: value }, { $rename: { old_field: new_field } } );
864
-
865
- Here, the :operator:`$rename` operator changes the name of the ``old_field``
866
- field to ``new_field``, in the document that matches the query ``{
867
- field: value }`` in ``collection``.
868
-
869
- The :operator:`$rename` operator will expand arrays and
870
- sub-documents to find a match for field names (e.g. ``old_field``
871
- in the example above.)
872
-
873
- .. versionadded:: 1.7.2
915
+ Bitwise
916
+ ~~~~~~~
874
917
875
918
.. operator:: $bit
876
919
@@ -885,6 +928,13 @@ Update
885
928
named ``field`` with a bitwise ``and: 5`` operation. This
886
929
operator only works with number types.
887
930
931
+ .. index:: update operators; isolation
932
+ .. _operators-update-isolation:
933
+ .. _update-operators-isolation:
934
+
935
+ Isolation
936
+ ~~~~~~~~~
937
+
888
938
.. operator:: $atomic
889
939
890
940
In multi-update mode, it's possible to specify an
@@ -905,6 +955,7 @@ Update
905
955
.. seealso:: See :func:`db.collection.update()` for more information about the
906
956
:func:`db.collection.update()` method.
907
957
958
+ .. index:: projection operators
908
959
.. _projection-operators:
909
960
910
961
Projection
0 commit comments