1
0
Fork 0

docu resetted to automatation

This commit is contained in:
gschwab 2014-06-18 15:53:28 +02:00
parent 10ff1d391c
commit 1338fb0dce
1 changed files with 21 additions and 520 deletions

View File

@ -12,124 +12,19 @@ The edge definitions for a graph is an Array containing arbitrary many directed
!SUBSECTION Initialize the list !SUBSECTION Initialize the list
<br /> @startDocuBlock JSF_general_graph_edge_definitions
The edge definitions for a graph is an array containing arbitrary many directed
and/or undirected relations as defined below.
The list of edge definitions of a graph can be managed by the graph module itself.
This function is the entry point for the management and will return the correct list.
<br />
@EXAMPLES
<br />
<br />
```
arangosh> var graph = require("org/arangodb/general-graph");
arangosh> directed-relation = graph._directedRelationDefinition("lives_in", "user", "city");
ReferenceError: Invalid left-hand side in assignment
```
<br />
!SUBSECTION Extend the list !SUBSECTION Extend the list
@startDocuBlock JSF_general_graph_extend_edge_definitions
<br />
In order to add more edge definitions to the graph before creating
this function can be used to add more definitions to the initial list.
<br />
@EXAMPLES
<br />
```
arangosh> var graph = require("org/arangodb/general-graph");
arangosh> directed-relation = graph._directedRelationDefinition("lives_in", "user", "city");
ReferenceError: Invalid left-hand side in assignment
```
<br />
!SUBSUBSECTION Undirected Relation !SUBSUBSECTION Undirected Relation
@startDocuBlock JSF_general_graph_undirectedRelationDefinition@startDocuBlock
<br />
`general-graph._undirectedRelationDefinition(relationName, vertexCollections)`
*Define an undirected relation.*
<br />
Defines an undirected relation with the name *relationName* using the
list of *vertexCollections*. This relation allows the user to store
edges in any direction between any pair of vertices within the
*vertexCollections*.
<br />
@EXAMPLES
<br />
To define simple relation with only one vertex collection:
<br />
```
arangosh> var graph = require("org/arangodb/general-graph");
arangosh> graph._undirectedRelationDefinition("friend", "user");
{
"collection" : "friend",
"from" : [
"user"
],
"to" : [
"user"
]
}
```
<br />
To define a relation between several vertex collections:
<br />
```
arangosh> var graph = require("org/arangodb/general-graph");
arangosh> graph._undirectedRelationDefinition("marriage", ["female", "male"]);
{
"collection" : "marriage",
"from" : [
"female",
"male"
],
"to" : [
"female",
"male"
]
}
```
!SUBSUBSECTION Directed Relation !SUBSUBSECTION Directed Relation
@startDocuBlock JSF_general_graph_directedRelationDefinition
<br />
`general-graph._directedRelationDefinition(relationName, fromVertexCollections, toVertexCollections)`
*Define a directed relation.*
<br />
The *relationName* defines the name of this relation and references to the underlying edge collection.
The *fromVertexCollections* is an Array of document collections holding the start vertices.
The *toVertexCollections* is an Array of document collections holding the target vertices.
Relations are only allowed in the direction from any collection in *fromVertexCollections*
to any collection in *toVertexCollections*.
<br />
@EXAMPLES
<br />
```
arangosh> var graph = require("org/arangodb/general-graph");
arangosh> graph._directedRelationDefinition("has_bought", ["Customer", "Company"], ["Groceries", "Electronics"]);
{
"collection" : "has_bought",
"from" : [
"Customer",
"Company"
],
"to" : [
"Groceries",
"Electronics"
]
}
```
!SUBSECTION Orphan Collections !SUBSECTION Orphan Collections
@ -139,131 +34,21 @@ it will be removed from the orphan collection automatically.
!SUBSUBSECTION Add !SUBSUBSECTION Add
@startDocuBlock JSF_general_graph__addVertexCollection
Adds a vertex collection to the set of orphan collections of the graph. If the
collection does not exist, it will be created.
<br />
`general-graph._addOrphanCollection(orphanCollectionName, createCollection)`
<br />
* *orphanCollectionName* - string : name of vertex collection.
* *createCollection* - bool : if true the collection will be created if it does not exist. Default: true.
<br />
@EXAMPLES
<br />
```
arangosh> var graph = require("org/arangodb/general-graph")
arangosh> var ed1 = graph._directedRelationDefinition("myEC1", ["myVC1"], ["myVC2"]);
arangosh> var g = graph._create("myGraph", [ed1]);
arangosh> g._addOrphanCollection("myVC3", true);
undefined
```
<br />
!SUBSUBSECTION Read !SUBSUBSECTION Read
@startDocuBlock JSF_general_graph__orphanCollections
Returns all vertex collections of the graph, that are not used in an edge definition.
<br />
`general-graph._getOrphanCollections()`
<br />
@EXAMPLES
<br />
```
arangosh> var graph = require("org/arangodb/general-graph")
arangosh> var ed1 = graph._directedRelationDefinition("myEC1", ["myVC1"], ["myVC2"]);
arangosh> var g = graph._create("myGraph", [ed1]);
arangosh> g._addOrphanCollection("myVC3", true);
undefined
arangosh> g._getOrphanCollections();
[
"myVC3"
]
```
<br />
!SUBSUBSECTION Remove !SUBSUBSECTION Remove
@startDocuBlock JSF_general_graph__removeVertexCollection
Removes an orphan collection from the graph and deletes the collection, if it is not
used in any graph.
<br />
`general-graph._removeOrphanCollection()`
<br />
*orphanCollectionName* - string : name of vertex collection.
*dropCollection* - bool : if true the collection will be dropped if it is not used in any graph.
Default: true.
<br />
@EXAMPLES
<br />
```
arangosh> var graph = require("org/arangodb/general-graph")
arangosh> var ed1 = graph._directedRelationDefinition("myEC1", ["myVC1"], ["myVC2"]);
arangosh> var g = graph._create("myGraph", [ed1]);
arangosh> g._addOrphanCollection("myVC3", true);
undefined
arangosh> g._addOrphanCollection("myVC4", true);
undefined
arangosh> g._getOrphanCollections();
[
"myVC3",
"myVC4"
]
arangosh> g._removeOrphanCollection("myVC3");
undefined
arangosh> g._getOrphanCollections();
[
"myVC4"
]
```
<br />
!SECTION Create a graph !SECTION Create a graph
After having introduced edge definitions and orphan collections a graph can be created. After having introduced edge definitions and orphan collections a graph can be created.
@startDocuBlock JSF_general_graph_create
`general-graph._create(graph-name, edge-definitions, orphan-collections)`
*Create a graph*
<br />
<br />
The creation of a graph requires the name of the graph and a definition of its edges.
<br />
For every type of edge definition a convenience method exists that can be used to create a graph.
Optionaly a list of vertex collections can be added, which are not used in any edge definition.
These collections are refered to as orphan collections within this chapter.
All collections used within the creation process are created if they do not exist.
<br />
* *graph-name*: string - unique identifier of the graph
* *edge-definitions*: array - list of edge definition objects
* *orphan-collections*: array - list of additonal vertex collection names
<br />
@EXAMPLES
<br />
Create an empty graph, edge definitions can be added at runtime:
<br />
```
arangosh> var graph = require("org/arangodb/general-graph");
arangosh> graph._drop("social");
true
```
<br />
Create a graph with edge definitions and orphan collections:
<br />
```
arangosh> var graph = require("org/arangodb/general-graph");
arangosh> graph._drop("social");
true
```
<br />
!SUBSUBSECTION Complete Example to create a graph !SUBSUBSECTION Complete Example to create a graph
@ -298,343 +83,59 @@ alternative call:
!SUBSECTION List available graphs !SUBSECTION List available graphs
@startDocuBlock JSF_general_graph_list_call
`general-graph._list()` *List all graphs.* `general-graph._list()` *List all graphs.*
<br /> <br />
<br /> <br />
@startDocuBlock JSF_general_graph_list_info
Lists all graph names stored in this database.
<br /> <br />
@EXAMPLES @EXAMPLES
<br /> <br />
@startDocuBlock JSF_general_graph_list_examples
<br />
```
arangosh> var graph = require("org/arangodb/general-graph");
arangosh> graph._list();
[
"social"
]
```
!SUBSECTION Load a graph !SUBSECTION Load a graph
@startDocuBlock JSF_general_graph_graph
`general-graph._graph(graph-name)`
*Load a graph*
<br />
A graph can be loaded by its name.
<br />
* *graph-name*: string - unique identifier of the graph
<br />
@EXAMPLES
<br />
Load a graph:
<br />
```
arangosh> var graph = require("org/arangodb/general-graph");
arangosh> graph._drop("social");
true
```
<br />
!SUBSECTION Remove a graph !SUBSECTION Remove a graph
@startDocuBlock JSF_general_graph_drop
`general-graph._drop(graph-name, drop-collections)`
*Remove a graph*
<br />
A graph can be dropped by its name.
This will automatically drop al collections contained in the graph as
long as they are not used within other graphs.
To prohibit the drop of collections, the optional parameter *drop-collections* can be set to *false*.
<br />
* *graph-name*: string - unique identifier of the graph
* *drop-collections*: boolean (optional) - Define if collections should be dropped (default: true)
<br />
@EXAMPLES
<br />
Drop a graph:
<br />
```
arangosh> var graph = require("org/arangodb/general-graph");
arangosh> graph._drop("social");
true
```
<br />
!SECTION Edge !SECTION Edge
!SUBSECTION Save !SUBSECTION Save
@startDocuBlock JSF_general_graph_vertex_collection_save
Creates and saves a new vertex in collection *vertexCollectionName*
<br />
`general-graph.vertexCollectionName.save(data)`
<br />
*data*: json - data of vertex
<br />
@EXAMPLES
<br />
```
arangosh> var graph = require("org/arangodb/general-graph");
arangosh> graph._drop("social");
true
```
<br />
!SUBSECTION Replace !SUBSECTION Replace
@startDocuBlock JSF_general_graph_vertex_collection_replace
Replaces the data of a vertex in collection *vertexCollectionName*
<br />
`general-graph.vertexCollectionName.replace(vertexId, data, options)`
<br />
*vertexId*: string - id of the vertex
*data*: json - data of vertex
*options*: json - (optional) - see collection documentation
<br />
@EXAMPLES
<br />
```
arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js");
arangosh> var g = examples.loadGraph("social");
arangosh> g.male.save({neym: "Jon", _key: "john"});
{
"error" : false,
"_id" : "male/john",
"_rev" : "31374924",
"_key" : "john"
}
arangosh> g.male.replace("male/john", {name: "John"});
{
"error" : false,
"_id" : "male/john",
"_rev" : "31571532",
"_key" : "john"
}
```
<br />
!SUBSECTION Update !SUBSECTION Update
@startDocuBlock JSF_general_graph_vertex_collection_update
Updates the data of a vertex in collection *vertexCollectionName*
<br />
`general-graph.vertexCollectionName.update(vertexId, data, options)`
<br />
*vertexId*: string - id of the vertex
*data*: json - data of vertex
*options*: json - (optional) - see collection documentation
<br />
@EXAMPLES
<br />
```
arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js");
arangosh> var g = examples.loadGraph("social");
arangosh> g.female.save({name: "Lynda", _key: "linda"});
{
"error" : false,
"_id" : "female/linda",
"_rev" : "86027478",
"_key" : "linda"
}
arangosh> g.female.update("female/linda", {name: "Linda", _key: "linda"});
{
"error" : false,
"_id" : "female/linda",
"_rev" : "86224086",
"_key" : "linda"
}
```
<br />
!SUBSECTION Remove !SUBSECTION Remove
@startDocuBlock JSF_general_graph_vertex_collection_remove
Removes a vertex in collection *vertexCollectionName*
<br />
`general-graph.vertexCollectionName.remove(vertexId, options)`
<br />
Additionally removes all ingoing and outgoing edges of the vertex recursively
(see [edge remove](#edge.remove)).
<br />
@EXAMPLES
<br />
```
arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js");
arangosh> var g = examples.loadGraph("social");
arangosh> g.male.save({name: "Kermit", _key: "kermit"});
{
"error" : false,
"_id" : "male/kermit",
"_rev" : "89701964",
"_key" : "kermit"
}
arangosh> db._exists("male/kermit")
true
arangosh> g.male.remove("male/kermit")
true
arangosh> db._exists("male/kermit")
false
```
<br />
!SECTION Edge !SECTION Edge
!SUBSECTION Save !SUBSECTION Save
@startDocuBlock JSF_general_graph_edge_collection_save
Creates and saves a new edge from vertex *from* to vertex *to* in
collection *edgeCollectionName*
<br />
`general-graph.edgeCollectionName.save(from, to, data)`
<br />
*from*: string - id of outgoing vertex
*to*: string - of ingoing vertex
*data*: json - data of edge
<br />
@EXAMPLES
<br />
```
arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js");
arangosh> var g = examples.loadGraph("social");
arangosh> g.relation.save("male/bob", "female/alice", {type: "married", _key: "bobAndAlice"});
{
"error" : false,
"_id" : "relation/bobAndAlice",
"_rev" : "45923916",
"_key" : "bobAndAlice"
}
```
<br />
If the collections of *from* and *to* are not defined in an edgeDefinition of the graph,
the edge will not be stored.
<br />
<br />
```
arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js");
arangosh> var g = examples.loadGraph("social");
arangosh> g.relation.save("relation/aliceAndBob", "female/alice", {type: "married", _key: "bobAndAlice"});
Edge is not allowed between relation/aliceAndBob and female/alice.
```
!SUBSECTION Replace !SUBSECTION Replace
@startDocuBlock JSF_general_graph_edge_collection_replace
Replaces the data of an edge in collection *edgeCollectionName*
<br />
`general-graph.edgeCollectionName.replace(edgeId, data, options)`
<br />
*edgeId*: string - id of the edge
*data*: json - data of edge
*options*: json - (optional) - see collection documentation
<br />
@EXAMPLES
<br />
```
arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js");
arangosh> var g = examples.loadGraph("social");
arangosh> g.relation.save("female/alice", "female/diana", {typo: "nose", _key: "aliceAndDiana"});
{
"error" : false,
"_id" : "relation/aliceAndDiana",
"_rev" : "27377228",
"_key" : "aliceAndDiana"
}
arangosh> g.relation.replace("relation/aliceAndDiana", {type: "knows"});
{
"error" : false,
"_id" : "relation/aliceAndDiana",
"_rev" : "27573836",
"_key" : "aliceAndDiana"
}
```
<br />
!SUBSECTION Update !SUBSECTION Update
@startDocuBlock JSF_general_graph_edge_collection_update
Updates the data of an edge in collection *edgeCollectionName*
<br />
`general-graph.edgeCollectionName.update(edgeId, data, options)`
<br />
*edgeId*: string - id of the edge
*data*: json - data of edge
*options*: json - (optional) - see collection documentation
<br />
@EXAMPLES
<br />
```
arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js");
arangosh> var g = examples.loadGraph("social");
arangosh> g.relation.save("female/alice", "female/diana", {type: "knows", _key: "aliceAndDiana"});
{
"error" : false,
"_id" : "relation/aliceAndDiana",
"_rev" : "132365900",
"_key" : "aliceAndDiana"
}
arangosh> g.relation.update("relation/aliceAndDiana", {type: "quarrelled", _key: "aliceAndDiana"});
{
"error" : false,
"_id" : "relation/aliceAndDiana",
"_rev" : "132562508",
"_key" : "aliceAndDiana"
}
```
<br />
!SUBSECTION Remove !SUBSECTION Remove
@startDocuBlock JSF_general_graph_edge_collection_remove
Removes an edge in collection *edgeCollectionName*
<br />
`general-graph.edgeCollectionName.remove(edgeId, options)`
<br />
If this edge is used as a vertex by another edge, the other edge will be removed (recursively).
<br />
@EXAMPLES
<br />
```
arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js");
arangosh> var g = examples.loadGraph("social");
arangosh> g.relation.save("female/alice", "female/diana", {_key: "aliceAndDiana"});
{
"error" : false,
"_id" : "relation/aliceAndDiana",
"_rev" : "146914892",
"_key" : "aliceAndDiana"
}
arangosh> db._exists("relation/aliceAndDiana")
true
arangosh> g.relation.remove("relation/aliceAndDiana")
true
arangosh> db._exists("relation/aliceAndDiana")
false
```
<br />