JavaScript Interface for Views
This is an introduction to ArangoDB’s interface for views and how to handle
views from the JavaScript shell arangosh . For other languages see the
corresponding language API.
Like collections , views are accessed by the user via
their unique name and internally via their identifier. Using the identifier for
accessing views is discouraged. Views share their namespace with collections,
so there cannot exist a view and a collection with the same name in the same
database.
Here follow some basic usage examples. More details can be found in the
following chapters:
Create a view with default properties:
Permalink
arangosh> view = db._createView("myView" , "arangosearch" , {});
[ArangoView 82453 , "myView" (type arangosearch)]
Get this view again later by name:
Permalink
arangosh> view = db._view("myView" );
[ArangoView 82453 , "myView" (type arangosearch)]
Get the view properties:
Permalink
arangosh> view.properties();
{
"writebufferSizeMax" : 33554432 ,
"writebufferIdle" : 64 ,
"consolidationIntervalMsec" : 1000 ,
"consolidationPolicy" : {
"type" : "tier" ,
"segmentsBytesFloor" : 2097152 ,
"segmentsBytesMax" : 5368709120 ,
"segmentsMax" : 10 ,
"segmentsMin" : 1 ,
"minScore" : 0
},
"writebufferActive" : 0 ,
"commitIntervalMsec" : 1000 ,
"links" : {
},
"storedValues" : [ ],
"cleanupIntervalStep" : 2 ,
"primarySort" : [ ],
"primarySortCompression" : "lz4"
}
Set a view property:
Permalink
arangosh> view.properties({cleanupIntervalStep : 12 });
{
"cleanupIntervalStep" : 12 ,
"commitIntervalMsec" : 1000 ,
"consolidationIntervalMsec" : 1000 ,
"consolidationPolicy" : {
"type" : "tier" ,
"segmentsBytesFloor" : 2097152 ,
"segmentsBytesMax" : 5368709120 ,
"segmentsMax" : 10 ,
"segmentsMin" : 1 ,
"minScore" : 0
},
"primarySort" : [ ],
"primarySortCompression" : "lz4" ,
"storedValues" : [ ],
"writebufferActive" : 0 ,
"writebufferIdle" : 64 ,
"writebufferSizeMax" : 33554432 ,
"links" : {
}
}
Add a link:
Permalink
arangosh> view.properties({links : {colA : {includeAllFields : true }}});
{
"cleanupIntervalStep" : 12 ,
"commitIntervalMsec" : 1000 ,
"consolidationIntervalMsec" : 1000 ,
"consolidationPolicy" : {
"type" : "tier" ,
"segmentsBytesFloor" : 2097152 ,
"segmentsBytesMax" : 5368709120 ,
"segmentsMax" : 10 ,
"segmentsMin" : 1 ,
"minScore" : 0
},
"primarySort" : [ ],
"primarySortCompression" : "lz4" ,
"storedValues" : [ ],
"writebufferActive" : 0 ,
"writebufferIdle" : 64 ,
"writebufferSizeMax" : 33554432 ,
"links" : {
"colA" : {
"analyzers" : [
"identity"
],
"fields" : {
},
"includeAllFields" : true ,
"storeValues" : "none" ,
"trackListPositions" : false
}
}
}
Add another link:
Permalink
arangosh> view.properties({links : {colB : {fields : {text : {}}}}});
{
"cleanupIntervalStep" : 12 ,
"commitIntervalMsec" : 1000 ,
"consolidationIntervalMsec" : 1000 ,
"consolidationPolicy" : {
"type" : "tier" ,
"segmentsBytesFloor" : 2097152 ,
"segmentsBytesMax" : 5368709120 ,
"segmentsMax" : 10 ,
"segmentsMin" : 1 ,
"minScore" : 0
},
"primarySort" : [ ],
"primarySortCompression" : "lz4" ,
"storedValues" : [ ],
"writebufferActive" : 0 ,
"writebufferIdle" : 64 ,
"writebufferSizeMax" : 33554432 ,
"links" : {
"colA" : {
"analyzers" : [
"identity"
],
"fields" : {
},
"includeAllFields" : true ,
"storeValues" : "none" ,
"trackListPositions" : false
},
"colB" : {
"analyzers" : [
"identity"
],
"fields" : {
"text" : {
}
},
"includeAllFields" : false ,
"storeValues" : "none" ,
"trackListPositions" : false
}
}
}
Remove the first link again:
Permalink
arangosh> view.properties({links : {colA : null }});
{
"cleanupIntervalStep" : 12 ,
"commitIntervalMsec" : 1000 ,
"consolidationIntervalMsec" : 1000 ,
"consolidationPolicy" : {
"type" : "tier" ,
"segmentsBytesFloor" : 2097152 ,
"segmentsBytesMax" : 5368709120 ,
"segmentsMax" : 10 ,
"segmentsMin" : 1 ,
"minScore" : 0
},
"primarySort" : [ ],
"primarySortCompression" : "lz4" ,
"storedValues" : [ ],
"writebufferActive" : 0 ,
"writebufferIdle" : 64 ,
"writebufferSizeMax" : 33554432 ,
"links" : {
"colB" : {
"analyzers" : [
"identity"
],
"fields" : {
"text" : {
}
},
"includeAllFields" : false ,
"storeValues" : "none" ,
"trackListPositions" : false
}
}
}
Drop the view: