JavaScript Interface to 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.

Address of a View

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.

Usage

Here follow some basic usage examples. More details can be found in the following chapters:

Create a view with default properties:

arangosh> view = db._createView("myView", "arangosearch", {});
Show execution results
[ArangoView 133006, "myView" (type arangosearch)]
Hide execution results

Get this view again later by name:

arangosh> view = db._view("myView");
Show execution results
[ArangoView 133006, "myView" (type arangosearch)]
Hide execution results

Get the view properties:

arangosh> view.properties();
Show execution results
{ 
  "writebufferSizeMax" : 33554432, 
  "consolidationPolicy" : { 
    "type" : "bytes_accum", 
    "threshold" : 0.10000000149011612 
  }, 
  "writebufferActive" : 0, 
  "consolidationIntervalMsec" : 60000, 
  "cleanupIntervalStep" : 10, 
  "links" : { 
  }, 
  "writebufferIdle" : 64 
}
Hide execution results

Set a view property:

arangosh> view.properties({cleanupIntervalStep: 12});
Show execution results
{ 
  "cleanupIntervalStep" : 12, 
  "consolidationIntervalMsec" : 60000, 
  "consolidationPolicy" : { 
    "type" : "bytes_accum", 
    "threshold" : 0.10000000149011612 
  }, 
  "writebufferActive" : 0, 
  "writebufferIdle" : 64, 
  "writebufferSizeMax" : 33554432, 
  "links" : { 
  } 
}
Hide execution results

Add a link:

arangosh> view.properties({links: {colA: {includeAllFields: true}}});
Show execution results
{ 
  "cleanupIntervalStep" : 12, 
  "consolidationIntervalMsec" : 60000, 
  "consolidationPolicy" : { 
    "type" : "bytes_accum", 
    "threshold" : 0.10000000149011612 
  }, 
  "writebufferActive" : 0, 
  "writebufferIdle" : 64, 
  "writebufferSizeMax" : 33554432, 
  "links" : { 
    "colA" : { 
      "analyzers" : [ 
        "identity" 
      ], 
      "fields" : { 
      }, 
      "includeAllFields" : true, 
      "storeValues" : "none", 
      "trackListPositions" : false 
    } 
  } 
}
Hide execution results

Add another link:

arangosh> view.properties({links: {colB: {fields: {text: {}}}}});
Show execution results
{ 
  "cleanupIntervalStep" : 12, 
  "consolidationIntervalMsec" : 60000, 
  "consolidationPolicy" : { 
    "type" : "bytes_accum", 
    "threshold" : 0.10000000149011612 
  }, 
  "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 
    } 
  } 
}
Hide execution results

Remove the first link again:

arangosh> view.properties({links: {colA: null}});
Show execution results
{ 
  "cleanupIntervalStep" : 12, 
  "consolidationIntervalMsec" : 60000, 
  "consolidationPolicy" : { 
    "type" : "bytes_accum", 
    "threshold" : 0.10000000149011612 
  }, 
  "writebufferActive" : 0, 
  "writebufferIdle" : 64, 
  "writebufferSizeMax" : 33554432, 
  "links" : { 
    "colB" : { 
      "analyzers" : [ 
        "identity" 
      ], 
      "fields" : { 
        "text" : { 
        } 
      }, 
      "includeAllFields" : false, 
      "storeValues" : "none", 
      "trackListPositions" : false 
    } 
  } 
}
Hide execution results

Drop the view:

arangosh> db._dropView("myView");
Show execution results

        
Hide execution results