Docs HomeMongoDB for VS Code

Perform CRUD Operations执行CRUD操作

Documents are individual records in a MongoDB collection and are the basic unit of data in MongoDB.文档是MongoDB集合中的单个记录,是MongoDB中的基本数据单元。

You can use a MongoDB Playground to perform CRUD (create, read, update, and delete) operations on documents in a collection on a connected deployment.您可以使用MongoDB Playground对连接部署的集合中的文档执行CRUD(创建、读取、更新和删除)操作。

Use the MongoDB CRUD Operators and shell methods to interact with your databases in MongoDB Playgrounds.使用MongoDB CRUD 运算符shell方法与MongoDB Playgrounds中的数据库进行交互。

Note

You can also use your application to perform CRUD operations on documents using the appropriate driver. 您还可以使用应用程序使用适当的驱动程序对文档执行CRUD操作。Playgrounds are meant to help you prototype database operations as you develop your application.Playgrounds旨在帮助您在开发应用程序时建立数据库操作的原型。

Open a Playground to Perform CRUD Operations打开演练场执行CRUD操作

Before you can create, read, update, and delete documents using a MongoDB Playground, you must open one.在使用MongoDB Playground创建、读取、更新和删除文档之前,必须先打开一个。

1

Open the Visual Studio Code Command Palette.打开Visual Studio Code“命令面板”。

In Visual Studio Code, press one of the following key combinations:在Visual Studio Code中,按以下组合键之一:

  • Control + Shift + P on Windows or Linux.
  • Command + Shift + P on macOS.

The Command Palette provides quick access to commands and keyboard shortcuts.“命令面板”提供了对命令和键盘快捷键的快速访问。

2

Find and run the "Create MongoDB Playground" command.找到并运行“创建MongoDB演练场”命令。

Use the Command Palette search bar to search for commands. 使用“命令面板”搜索栏可以搜索命令。All commands related to MongoDB for VS Code are prefaced with MongoDB:.所有与MongoDB for VS Code相关的命令都以MongoDB:开头。

When you run the MongoDB: Create MongoDB Playground command, MongoDB for VS Code opens a default playground template pre-configured with a few commands.当您运行“MongoDB:创建MongoDB演练场命令”时,MongoDB for VS Code会打开一个默认的演练场模板,该模板预先配置了一些命令。

Note

To load new Playgrounds without the template, disable the Use Default Template For Playground setting. 若要加载不带模板的新演练场,请禁用“为演练场使用默认模板”设置。To learn more about MongoDB for VS Code settings, see MongoDB for VS Code Settings.要了解有关MongoDB for VS Code设置的更多信息,请参阅MongoDB for VSCode设置