Docs Home / VS Code Extension / Explore with Playgrounds

Perform CRUD Operations with VS Code使用VS Code执行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游乐场对连接部署上的集合中的文档执行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. Playgrounds are meant to help you prototype database operations as you develop your application.您还可以使用应用程序使用适当的驱动程序对文档执行CRUD操作。游乐场旨在帮助您在开发应用程序时原型化数据库操作。

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.Windows或Linux上的Control+Shift+P
  • Command + Shift + P on macOS.macOS上的Command+Shift+P

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 VS Code Extension are prefaced with MongoDB:.使用“命令选项板”搜索栏搜索命令。所有与VS Code扩展相关的命令都以MongoDB开头:。

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

Note

To load new Playgrounds without the template, disable the Use Default Template For Playground setting. To learn more about VS Code Extension settings, see Visual Studio Code Settings.要加载没有模板的新游乐场,请禁用“使用默认游乐场模板”设置。要了解有关VS Code扩展设置的更多信息,请参阅Visual Studio Code设置