JavaScript Interface to Views

This is an introduction to ArangoDB’s interface for views and how to handleviews from the JavaScript shell arangosh. For other languages see thecorresponding language API.

Address of a View

Like collections, views are accessed by the user viatheir unique name and internally via their identifier. Using the identifier foraccessing views is discouraged. Views share their namespace with collections,so there cannot exist a view and a collection with the same name in the samedatabase.

Usage

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

  1. arangosh> view = db._createView("myView", "arangosearch", {});

Show execution results

  1. [ArangoView 87629, "myView" (type arangosearch)]

Hide execution results

Get this view again later by name:

  1. arangosh> view = db._view("myView");

Show execution results

  1. [ArangoView 87629, "myView" (type arangosearch)]

Hide execution results

Get the view properties:

  1. arangosh> view.properties();

Show execution results

  1. {
  2. "writebufferSizeMax" : 33554432,
  3. "consolidationPolicy" : {
  4. "type" : "bytes_accum",
  5. "threshold" : 0.10000000149011612
  6. },
  7. "writebufferActive" : 0,
  8. "consolidationIntervalMsec" : 60000,
  9. "cleanupIntervalStep" : 10,
  10. "links" : {
  11. },
  12. "writebufferIdle" : 64
  13. }

Hide execution results

Set a view property:

  1. arangosh> view.properties({cleanupIntervalStep: 12});

Show execution results

  1. {
  2. "cleanupIntervalStep" : 12,
  3. "consolidationIntervalMsec" : 60000,
  4. "consolidationPolicy" : {
  5. "type" : "bytes_accum",
  6. "threshold" : 0.10000000149011612
  7. },
  8. "writebufferActive" : 0,
  9. "writebufferIdle" : 64,
  10. "writebufferSizeMax" : 33554432,
  11. "links" : {
  12. }
  13. }

Hide execution results

Add a link:

  1. arangosh> view.properties({links: {colA: {includeAllFields: true}}});

Show execution results

  1. {
  2. "cleanupIntervalStep" : 12,
  3. "consolidationIntervalMsec" : 60000,
  4. "consolidationPolicy" : {
  5. "type" : "bytes_accum",
  6. "threshold" : 0.10000000149011612
  7. },
  8. "writebufferActive" : 0,
  9. "writebufferIdle" : 64,
  10. "writebufferSizeMax" : 33554432,
  11. "links" : {
  12. "colA" : {
  13. "analyzers" : [
  14. "identity"
  15. ],
  16. "fields" : {
  17. },
  18. "includeAllFields" : true,
  19. "storeValues" : "none",
  20. "trackListPositions" : false
  21. }
  22. }
  23. }

Hide execution results

Add another link:

  1. arangosh> view.properties({links: {colB: {fields: {text: {}}}}});

Show execution results

  1. {
  2. "cleanupIntervalStep" : 12,
  3. "consolidationIntervalMsec" : 60000,
  4. "consolidationPolicy" : {
  5. "type" : "bytes_accum",
  6. "threshold" : 0.10000000149011612
  7. },
  8. "writebufferActive" : 0,
  9. "writebufferIdle" : 64,
  10. "writebufferSizeMax" : 33554432,
  11. "links" : {
  12. "colA" : {
  13. "analyzers" : [
  14. "identity"
  15. ],
  16. "fields" : {
  17. },
  18. "includeAllFields" : true,
  19. "storeValues" : "none",
  20. "trackListPositions" : false
  21. },
  22. "colB" : {
  23. "analyzers" : [
  24. "identity"
  25. ],
  26. "fields" : {
  27. "text" : {
  28. }
  29. },
  30. "includeAllFields" : false,
  31. "storeValues" : "none",
  32. "trackListPositions" : false
  33. }
  34. }
  35. }

Hide execution results

Remove the first link again:

  1. arangosh> view.properties({links: {colA: null}});

Show execution results

  1. {
  2. "cleanupIntervalStep" : 12,
  3. "consolidationIntervalMsec" : 60000,
  4. "consolidationPolicy" : {
  5. "type" : "bytes_accum",
  6. "threshold" : 0.10000000149011612
  7. },
  8. "writebufferActive" : 0,
  9. "writebufferIdle" : 64,
  10. "writebufferSizeMax" : 33554432,
  11. "links" : {
  12. "colB" : {
  13. "analyzers" : [
  14. "identity"
  15. ],
  16. "fields" : {
  17. "text" : {
  18. }
  19. },
  20. "includeAllFields" : false,
  21. "storeValues" : "none",
  22. "trackListPositions" : false
  23. }
  24. }
  25. }

Hide execution results

Drop the view:

  1. arangosh> db._dropView("myView");

Show execution results

  1.  

Hide execution results