Arangodb 简明教程

Crud Operations using Web Interface

在上一个章节中,我们学习了如何使用命令行 Arangosh 对文档执行各种操作。我们现在将学习如何使用网络界面执行同样的操作。首先,在浏览器的地址栏中输入以下地址 - [role="bare"] [role="bare"]http://your_server_ip:8529/_db/song_collection/_admin/aardvark/index.html#login 您将被定向到以下登录页面。

In our previous chapter, we learned how to perform various operations on documents with Arangosh, the command line. We will now learn how to perform the same operations using the web interface. To start with, put the following address - [role="bare"]http://your_server_ip:8529/_db/song_collection/_admin/aardvark/index.html#login in the address bar of your browser. You will be directed to the following login page.

login page

现在,输入用户名和密码。

Now, enter the username and password.

login username password

如果成功,将出现以下屏幕。我们需要为要处理的数据库做出选择,其中 _system 数据库是默认数据库。让我们选择 song_collection 数据库,然后单击绿色选项卡 −

If it is successful, the following screen appears. We need to make a choice for the database to work on, the _system database being the default one. Let us choose the song_collection database, and click on the green tab −

song collection

Creating a Collection

在本节中,我们将学习如何创建集合。按顶部导航栏中的集合选项卡。

In this section, we will learn how to create a collection. Press the Collections tab in the navigation bar at the top.

我们命令行添加的 songs 集合可见。单击它将显示条目。我们现在将使用网络界面添加一个 artists’ 集合。我们在 Arangosh 中创建的 songs 集合已经在那里了。在名称字段中,在出现的 New Collection 对话框中编写 artists 。可以安全地忽略高级选项,默认集合类型(即 Document)也是可以的。

Our command line added songs collection are visible. Clicking on that will show the entries. We will now add an artists’ collection using the web interface. Collection songs which we created with Arangosh is already there. In the Name field, write artists in the New Collection dialog box that appears. Advanced options can safely be ignored and the default collection type, i.e. Document, is fine.

creating collection

单击“保存”按钮将最终创建该集合,现在此页面上将同时显示两个集合。

Clicking on the Save button will finally create the collection, and now the two collections will be visible on this page.

Filling Up the Newly Created Collection with Documents

单击 artists 集合时,系统将会显示一个空集合 −

You will be presented with an empty collection on clicking the artists collection −

fillingup collection with documents

要添加文档,您需要单击放置在右上角的 + 号。当系统提示您输入一个 _key 时,输入 Affable_Balding 作为键。

To add a document, you need to click the + sign placed in the upper right corner. When you are prompted for a _key, enter Affable_Balding as the key.

现在,一个表单将用于添加和编辑文档的属性。有两种方式可以添加属性: GraphicalTree 。图形方式直观但很慢,因此,我们将切换到 Code 视图,并使用树形下拉菜单来选择它 −

Now, a form will appear to add and edit the attributes of the document. There are two ways of adding attributes: Graphical and Tree. The graphical way is intuitive but slow, therefore, we will switch to the Code view, using the Tree dropdown menu to select it −

tree dropdown menu

为简化过程,我们已经用 JSON 格式生成了样本数据,您可以将其复制并粘贴到查询编辑器区域 −

To make the process easier, we have created a sample data in the JSON format, which you can copy and then paste into the query editor area −

{"artist": "Johnny Mercer", "title":"Affable Balding Me", "composer": "Robert Emmett Dolan", "Year": 1950}

(注:只应该使用一对大括号;请参见下面的截图)

(Note: Only one pair of curly braces should be used; see the screenshot below)

created sample data in json format

您也许会注意到,我们在代码视图模式下对键和值都加了引号。现在,单击 Save 。在成功完成后,页面上会短暂出现一个绿色的闪光。

You can observe that we have quoted the keys and also the values in the code view mode. Now, click Save. Upon successful completion, a green flash appears on the page momentarily.

How to Read Documents

要读取文档,请返回到集合页面。

To read documents, go back to the Collections page.

当有人单击 artist 集合时,会显示一个新条目。

When one clicks on the artist collection, a new entry appears.

How to Update Documents

编辑文档中的条目很简单;您只需在文档概述中单击您想要编辑的行。此处将再次显示与创建新文档时相同的查询编辑器。

It is simple to edit the entries in a document; you just need to click on the row you wish to edit in the document overview. Here again the same query editor will be presented as when creating new documents.

Removing Documents

您可以按“ - ”图标删除文档。每行文档在末尾都有这个标记。它会提示您确认以避免不安全地删除。

You can delete the documents by pressing the ‘-’ icon. Every document row has this sign at the end. It will prompt you to confirm to avoid unsafe deletion.

此外,对于特定集合,还可以在 Collections Overview 页面上进行其他操作,如过滤文档、管理索引和导入数据。

Moreover, for a particular collection, other operations like filtering the documents, managing indexes, and importing data also exist on the Collections Overview page.

后续章节中,我们将讨论 Web 接口的重要功能,即 AQL 查询编辑器。

In our subsequent chapter, we will discuss an important feature of the Web Interface, i.e., the AQL query Editor.