mirror of https://gitee.com/bigwinds/arangodb
101 lines
6.6 KiB
HTML
101 lines
6.6 KiB
HTML
<html><head><title>ArangoDB Manual</title> <style media="screen" type="text/css" style="display:none">body{background-color:white;font:13px Helvetica,arial,freesans,clean,sans-serif;line-height:1.4;color:#333;}#access{font-size:16px;margin-left:12px;display:block;margin-left:10px;margin-right:10px;background-color:#F3F1EE!important;}#access a{border-right:1px solid #DBDEDF;color:#A49F96;display:block;line-height:38px;padding:0 10px;text-decoration:none;}#navigation ul{text-transform:uppercase;list-style:none;margin:0;}#navigation li{float:left;position:relative;}#container{width:920px;margin:0 auto;}a{color:#4183C4;text-decoration:none;}.contents h2{font-size:24px;border-bottom:1px solid #CCC;color:black;}.contents h1{font-size:33px;border-bottom:1px solid #CCC;color:black;}.clearfix:after{content:".";display:block;clear:both;font-size:0;height:0;visibility:hidden;}/**/ *:first-child+html .clearfix{min-height:0;}/**/ * html .clearfix{height:1%;}</style></head><body><div id="container"><img src="images/logo_arangodb.png" width="397" height="67" alt="ArangoDB"><div id="access" role="navigation"><div id="navigation"><ul id="menu-ahome" class="menu"><li><a href="Home.html">Table of contents</a></li> <li><a href="http://www.arangodb.org">ArangoDB homepage</a></li></ul></div><div class="clearfix"></div></div><div>
|
|
<!-- Generated by Doxygen 1.7.5.1 -->
|
|
</div>
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<h1>First Steps with ArangoDB </h1> </div>
|
|
</div>
|
|
<div class="contents">
|
|
<div class="textblock"><hr/>
|
|
<ul>
|
|
<li>
|
|
<a class="el" href="FirstStepsArangoDB.html">First Steps with ArangoDB</a> <ul>
|
|
<li>
|
|
<a class="el" href="FirstStepsArangoDB.html#FirstStepsArangoDBServerStart">Starting the ArangoDB server</a> </li>
|
|
<li>
|
|
<a class="el" href="FirstStepsArangoDB.html#FirstStepsArangoDBFirstSteps">First Steps using arangosh</a> </li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<hr/>
|
|
<h2><a class="anchor" id="FirstStepsArangoDBServerStart"></a>
|
|
Starting the ArangoDB server</h2>
|
|
<p>Create an empty directory, which will hold the database:</p>
|
|
<p><code>> mkdir /tmp/vocbase</code></p>
|
|
<p>First start the ArgangoDB server. You can start it as daemon and redirect the output to a file as follows:</p>
|
|
<p><code>> ./arangod --daemon --pid-file /tmp/arangod.pid --log.file /tmp/arangod.log /tmp/vocbase</code></p>
|
|
<p>This will start the ArangoDB server process, store its process identifier in the file <code>/tmp/arangod.pid</code> and write the output to <code>/tmp/arangod.log</code>. The database files will live in <code>/tmp/vocbase</code>.</p>
|
|
<h2><a class="anchor" id="FirstStepsArangoDBFirstSteps"></a>
|
|
First Steps using arangosh</h2>
|
|
<h3><a class="anchor" id="FirstStepsArangoDBConnecting"></a>
|
|
Connecting to the server</h3>
|
|
<p>Start the ArangoDB JavaScript shell.</p>
|
|
<div class="fragment"><pre class="fragment">> ./arangosh
|
|
_
|
|
__ _ _ __ __ _ _ __ __ _ ___ ___| |__
|
|
/ _` | '__/ _` | '_ \ / _` |/ _ \/ __| '_ \
|
|
| (_| | | | (_| | | | | (_| | (_) \__ \ | | |
|
|
\__,_|_| \__,_|_| |_|\__, |\___/|___/_| |_|
|
|
|___/
|
|
|
|
Welcome to arangosh 1.x.y. Copyright (c) 2012 triAGENS GmbH.
|
|
Using Google V8 3.9.4 JavaScript engine.
|
|
Using READLINE 6.1.
|
|
|
|
Connected to Arango DB 127.0.0.1:8529 Version 1.x.y
|
|
|
|
------------------------------------- Help -------------------------------------
|
|
Predefined objects:
|
|
arango: ArangoConnection
|
|
db: ArangoDatabase
|
|
Example:
|
|
> db._collections(); list all collections
|
|
> db.<coll_name>.all(); list all documents
|
|
> id = db.<coll_name>.save({ ... }); save a document
|
|
> db.<coll_name>.remove(<_id>); delete a document
|
|
> db.<coll_name>.document(<_id>); get a document
|
|
> help show help pages
|
|
> helpQueries query help
|
|
> exit
|
|
arangosh>
|
|
</pre></div> <p>This gives you a prompt, where you can issue JavaScript commands.</p>
|
|
<p>You might need to specify the endpoint, username and password in order to run the shell on your system. You can use the options --server.endpoint, --server.username and --server.password for this. If you do not specify a password, arangosh will prompt for one.</p>
|
|
<div class="fragment"><pre class="fragment">> ./arangosh --server.endpoint tcp://127.0.0.1:8529 --server.username root
|
|
</pre></div><h3><a class="anchor" id="FirstStepsArangoDBQuerying"></a>
|
|
Querying</h3>
|
|
<p>All documents are stored in collections. All collections are stored in a database.</p>
|
|
<div class="fragment"><pre class="fragment">arangosh> db;
|
|
[object ArangoDatabase]
|
|
</pre></div><p>Creating a collection is simple. You can use the <code>_create</code> method of the <code>db</code> variable.</p>
|
|
<div class="fragment"><pre class="fragment">arangosh> db._create("example");
|
|
[ArangoCollection 70628, "example" (status loaded)]
|
|
</pre></div><p>After the collection has been create you can easily access it using the path <code>db.example</code>. The collection currently shows as <code>loaded</code>, meaning that its loaded into memory. If you restart the server and access the collection again, it will now show as <code>unloaded</code>. You can also manually unload a collection</p>
|
|
<div class="fragment"><pre class="fragment">arangosh> db.example.unload();
|
|
arangosh> db.example;
|
|
[ArangoCollection 70628, "example" (status unloaded)]
|
|
</pre></div><p>In order to create new documents in a collection, use the <code>save</code> operator. If the collection is currently unloaded, it will automatically be loaded into memory.</p>
|
|
<div class="fragment"><pre class="fragment">arangosh> db.example.save({ Hallo : "World" });
|
|
{ error : false, _id : "70628/1512420", _rev : 1512420 }
|
|
arangosh> db.example.save({ name : "Musterman", age : 29 });
|
|
{ error : false, _id : "70628/1774564", _rev : 1774564 }
|
|
</pre></div><p>In order to select all elements of a collection, one can use the <code>all</code> operator.</p>
|
|
<div class="fragment"><pre class="fragment">arangosh> start_pretty_print();
|
|
use pretty printing
|
|
arangosh> db.example.all().toArray();
|
|
[
|
|
{
|
|
_id : "70628/1774564",
|
|
_rev : 1774564,
|
|
age : 29,
|
|
name : "Musterman"
|
|
},
|
|
{
|
|
_id : "70628/1512420",
|
|
_rev : 1512420,
|
|
Hallo : "World"
|
|
}
|
|
]
|
|
</pre></div><p>This will select and print all documents. </p>
|
|
</div></div>
|
|
</div></body></html>
|