|
| 1 | +.. |query-api| replace:: Query API |
| 2 | + |
| 3 | +=================== |
| 4 | +MongoDB |query-api| |
| 5 | +=================== |
| 6 | + |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. contents:: On this page |
| 10 | + :local: |
| 11 | + :backlinks: none |
| 12 | + :depth: 1 |
| 13 | + :class: singlecol |
| 14 | + |
| 15 | +The MongoDB |query-api| is the mechanism that you use to interact with |
| 16 | +your data. |
| 17 | + |
| 18 | +The |query-api| comprises two ways to query data in MongoDB: |
| 19 | + |
| 20 | +- :doc:`CRUD Operations </crud>` |
| 21 | +- :doc:`Aggregation pipelines </core/aggregation-pipeline>` |
| 22 | + |
| 23 | +You can use the |query-api| to perform: |
| 24 | + |
| 25 | +- **Adhoc queries**. Explore your MongoDB data with :binary:`~bin.mongosh`, |
| 26 | + `Compass <https://docs.mongodb.com/compass/current/>`_ , |
| 27 | + `VSCode <https://code.visualstudio.com/docs/azure/mongodb>`_ |
| 28 | + or a MongoDB :driver:`driver </>`. |
| 29 | + |
| 30 | +- **Data transformations**. Use |
| 31 | + :doc:`aggregation pipelines </core/aggregation-pipeline>` to |
| 32 | + reshape your data and perform calculations. |
| 33 | + |
| 34 | +- **Document join support** Use :pipeline:`$lookup` and |
| 35 | + :pipeline:`$unionWith` to combine data from different collections. |
| 36 | + |
| 37 | +- **Graph and geospatial queries**. Use operators such as |
| 38 | + :query:`$geoWithin` and :pipeline:`$geoNear` to analyze geospatial |
| 39 | + data and :pipeline:`$graphLookup` for graph data. |
| 40 | + |
| 41 | +- **Full-text search**. Use the :pipeline:`$search` stage to |
| 42 | + perform efficient text search on your data. |
| 43 | + |
| 44 | +- **Indexing**. Improve your MongoDB query performance by using the correct |
| 45 | + :ref:`index type <indexes>` for your data architecture. |
| 46 | + |
| 47 | +- **On-demand materialized views**. Use :pipeline:`$out` and |
| 48 | + :pipeline:`$merge` to :doc:`create materialized views |
| 49 | + </core/materialized-views>` |
| 50 | + on common queries. |
| 51 | + |
| 52 | +- **Time series analysis**. Query and aggregate your time-stamped data |
| 53 | + with :ref:`time series collections <manual-timeseries-collection-create>`. |
| 54 | + |
| 55 | +Document Model |
| 56 | +-------------- |
| 57 | + |
| 58 | +A document in MongoDB is a data structure composed of field and value |
| 59 | +pairs. Documents are stored as BSON which is the binary representation of |
| 60 | +:term:`JSON`. This low level of abstraction helps you develop quicker |
| 61 | +and reduces the efforts around querying and data modeling. The document |
| 62 | +model provides several advantages, including: |
| 63 | + |
| 64 | +- Documents correspond to native data types in many programming |
| 65 | + languages. |
| 66 | + |
| 67 | +- Embedded documents and arrays reduce need for expensive joins. |
| 68 | + |
| 69 | +- Flexible schema. Documents do not need to have the same set of fields |
| 70 | + and the data type for a field can differ across documents within a |
| 71 | + collection. |
| 72 | + |
| 73 | +Data as Code |
| 74 | +------------ |
| 75 | + |
| 76 | +The MongoDB |query-api| supports :driver:`drivers</>` for major |
| 77 | +programming languages. These drivers allow you to make calls to the |
| 78 | +database and generate queries using the syntax native to your |
| 79 | +application. |
| 80 | + |
| 81 | +Getting Started |
| 82 | +--------------- |
| 83 | + |
| 84 | +To get started, visit the MongoDB |
| 85 | +:doc:`Getting Started Guide </tutorial/getting-started>`. Here you can |
| 86 | +find resources, code examples and tutorials that demonstrate the MongoDB |
| 87 | +|query-api|. |
0 commit comments