Docs HomeMongoDB Manual

MongoDB Query APIMongoDB查询API

The MongoDB Query API is the mechanism that you use to interact with your data.MongoDB Query API是用于与数据交互的机制。

The Query API comprises two ways to query data in MongoDB:查询API包括两种在MongoDB中查询数据的方法:

You can use the Query API to perform:您可以使用查询API来执行:

Document Model文档模型

A document in MongoDB is a data structure composed of field and value pairs. MongoDB中的文档是由字段和值对组成的数据结构。Documents are stored as BSON which is the binary representation of JSON. 文档存储为BSON,它是JSON的二进制表示。This low level of abstraction helps you develop quicker and reduces the efforts around querying and data modeling. 这种低级别的抽象可以帮助您更快地进行开发,并减少查询和数据建模方面的工作量。The document model provides several advantages, including:文档模型提供了几个优点,包括:

  • Documents correspond to native data types in many programming languages.文档对应于许多编程语言中的本机数据类型。
  • Embedded documents and arrays reduce need for expensive joins.嵌入式文档和数组减少了对昂贵联接的需求。
  • Flexible schema. Documents do not need to have the same set of fields and the data type for a field can differ across documents within a collection.灵活的架构。文档不需要具有相同的字段集,并且集合中不同文档的字段的数据类型可能不同。

Data as Code数据作为代码

The MongoDB Query API supports drivers for major programming languages. MongoDB Query API支持主要编程语言的驱动程序These drivers allow you to make calls to the database and generate queries using the syntax native to your application.这些驱动程序允许您调用数据库,并使用应用程序的本地语法生成查询。

Getting Started入门

To get started, visit the MongoDB Getting Started Guide. Here you can find resources, code examples and tutorials that demonstrate the MongoDB Query API.要开始,请访问MongoDB入门指南。在这里,您可以找到演示MongoDB Query API的资源、代码示例和教程。