For other attributes this may not be the case. Since the document key is guaranteed to be unique, no more than a single document will match this filter. The document key is used in this example, but any other attribute can also be used as an equivalent for filtering. The above query will give songs created after the year 1940 in the Result tab (see the image below). Operations like FILTER, SORT and LIMIT can be added to the For loop body to narrow and order the result. The result set will show the list of songs so far saved in the songs collection as shown in the screenshot below. To find all the songs in our database, let us once again run the following query, equivalent to a SELECT * FROM songs of an SQL-type database (because the editor memorizes the last query, press the *New* button to clean the editor) − In essence, AQL can perform the CRUD operations efficiently. The different operations can be creating new structures, filtering, selecting documents, modifying, or inserting documents into the database (refer the instantaneous example). This query describes how the FOR loop works in AQL it iterates over the list of JSON encoded documents, performing the coded operations on each one of the documents in the collection. It will write two new documents in the songs collection. Press the Execute button at the lower left. "Andre Previn", Year: 1974, _key: "All_Mucked" Title: "All Mucked Up", lyricist: "Johnny Mercer", composer:
Title: "Air-Minded Executive", lyricist: "Johnny Mercer",Ĭomposer: "Bernie Hanighen", Year: 1940, _key: "Air-Minded" Instead of typing, you can copy the following query, and paste it in the AQL editor − We add two new songs to the songs collection we have already created. Even reading a document's data will finish with a consistent unit of the data.
Reading or modifying queries will either conclude in whole or not at all. Please note that AQL is entirely ACID-compliant. Moreover, AQL can query as well modify the data, and thus complex queries can be created by combining both the processes. This feature is commonly known as a declarative property of the language. In AQL, a query represents the end result to be achieved, but not the process through which the end result is to be achieved. We will highlight few basic and commonly-used features of the AQL query editor. For a detailed reference, one can see the official documentation.
When need, you can switch to the editor from the result view and vice-versa, by clicking the Query or the Result tabs in the top right corner as shown in the image below −Īmong other things, the editor has syntax highlighting, undo/redo functionality, and query saving. As shown in the image below, in the web interface, press the AQL Editor tab placed at the top of the navigation bar. We have already discussed in our previous chapters that ArangoDB has developed its own query language and that it goes by the name AQL.
ARANGODB SORT HOW TO
In this chapter, we will discuss how to query the data with AQL.