in this chapter, we will discuss the different database methods in arangodb.
to start with, let us get the properties of the database −
- name
- id
- path
first, we invoke the arangosh. once, arangosh is invoked, we will list the databases we created so far −
we will use the following line of code to invoke arangosh −
127.0.0.1:8529@_system> db._databases()
output
[ "_system", "song_collection" ]
we see two databases, one _system created by default, and the second song_collection that we have created.
let us now shift to song_collection database with the following line of code −
127.0.0.1:8529@_system> db._usedatabase("song_collection")
output
true 127.0.0.1:8529@song_collection>
we will explore the properties of our song_collection database.
to find the name
we will use the following line of code to find the name.
127.0.0.1:8529@song_collection> db._name()
output
song_collection
to find the id −
we will use the following line of code to find the id.
song_collection
output
4838
to find the path −
we will use the following line of code to find the path.
127.0.0.1:8529@song_collection> db._path()
output
/var/lib/arangodb3/databases/database-4838
let us now check if we are in the system database or not by using the following line of code −
127.0.0.1:8529@song_collection&t; db._issystem()
output
false
it means we are not in the system database (as we have created and shifted to the song_collection). the following screenshot will help you understand this.
to get a particular collection, say songs −
we will use the following line of code the get a particular collection.
127.0.0.1:8529@song_collection> db._collection("songs")
output
[arangocollection 4890, "songs" (type document, status loaded)]
the line of code returns a single collection.
let us move to the essentials of the database operations with our subsequent chapters.