ArangoDB installation and use
ArangoDB is a multi model Distributed database that supports graphics, key value pairs and document data models. In this article, I will provide a detailed introduction to how to install and use ArangoDB, and demonstrate how to create data tables, insert, modify, query, and delete data.
Install ArangoDB:
1. Visit the ArangoDB official website( https://www.arangodb.com/ )And download the ArangoDB software package suitable for your operating system.
2. Unzip the downloaded software package to the directory of your choice.
3. Execute the corresponding installation program according to the requirements of the operating system.
Start ArangoDB:
1. Open a terminal or command prompt window.
2. Navigate to the directory where the ArangoDB software package is located.
3. Run the startup command, such as/ Arangod or/ Arangodb 'may vary depending on your operating system.
4. ArangoDB will start on the default port 8529, which you can access by accessing http://localhost:8529 To confirm if it is running.
5. Open the ArangoDB web console in a browser to access http://localhost:8529/_db/_system/_admin Enter the default username and password (username: root, password: blank). You can set the password when starting ArangoDB for the first time.
Create a data table:
1. In the ArangoDB web console, navigate to the "Collections" (or "Collections") tab.
2. Click on the 'Create Collection' button.
3. Enter the name and type of the collection. ArangoDB supports collections of documents, graphics, and key value pairs.
4. Click on the 'Create' button to create the collection.
Insert data:
const db = require('arangojs')();
const collection = db.collection('myCollection');
//Connect to database
db.database('myDatabase').then(() => {
//Insert Data
collection.save({ name: 'John', age: 30 })
. then (doc=>console. log ('Insert successful: ', doc));
})
. batch (err=>console. error ('connection to database failed: ', err));
Modify data:
const db = require('arangojs')();
const collection = db.collection('myCollection');
//Connect to database
db.database('myDatabase').then(() => {
//Modify data
collection.update('myDocumentKey', { age: 35 })
. then (doc=>console. log ('modified successfully: ', doc));
})
. batch (err=>console. error ('connection to database failed: ', err));
Query data:
const db = require('arangojs')();
const collection = db.collection('myCollection');
//Connect to database
db.database('myDatabase').then(() => {
//Query data
collection.byExample({ age: 30 })
.then(cursor => cursor.next())
. then (doc=>console. log ('Query results: ', doc));
})
. batch (err=>console. error ('connection to database failed: ', err));
Delete data:
const db = require('arangojs')();
const collection = db.collection('myCollection');
//Connect to database
db.database('myDatabase').then(() => {
//Delete data
collection.remove('myDocumentKey')
. then (()=>console. log ('deleted successfully ');
})
. batch (err=>console. error ('connection to database failed: ', err));
Through the above steps, you can successfully install, start, and use ArangoDB, as well as insert, modify, query, and delete data. According to your actual needs, you can further understand the functions and advanced usage of ArangoDB to take full advantage of its Multi-model database.