/
gte.txt
46 lines (30 loc) · 1.18 KB
/
gte.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
====
$gte
====
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
.. query:: $gte
*Syntax*: ``{field: {$gte: value} }``
:query:`$gte` selects the documents where the value of the
``field`` is greater than or equal to (i.e. ``>=``) a specified
value (e.g. ``value``.)
.. include:: /includes/fact-type-bracketing.rst
Consider the following example:
.. code-block:: javascript
db.inventory.find( { qty: { $gte: 20 } } )
This query would select all documents in ``inventory`` where
the ``qty`` field value is greater than or equal to ``20``.
Consider the following example which uses the :query:`$gte`
operator with a field from an embedded document:
.. code-block:: javascript
db.inventory.update( { "carrier.fee": { $gte: 2 } }, { $set: { price: 9.99 } } )
This :method:`~db.collection.update()` operation will set
the value of the ``price`` field that contain the embedded document
``carrier`` whose ``fee`` field value is greater than or equal to
``2``.
.. seealso::
:method:`~db.collection.find()`, :method:`~db.collection.update()`, :update:`$set`.