JavaScript Interface for 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 88658, "myView" (type arangosearch)]

Hide execution results

Get this view again later by name:

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

Show execution results

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

Hide execution results

Get the view properties:

  1. arangosh> view.properties();

Show execution results

  1. {
  2. "writebufferIdle" : 64,
  3. "writebufferActive" : 0,
  4. "primarySort" : [ ],
  5. "writebufferSizeMax" : 33554432,
  6. "commitIntervalMsec" : 1000,
  7. "consolidationPolicy" : {
  8. "type" : "tier",
  9. "segmentsBytesFloor" : 2097152,
  10. "segmentsBytesMax" : 5368709120,
  11. "segmentsMax" : 10,
  12. "segmentsMin" : 1,
  13. "minScore" : 0
  14. },
  15. "cleanupIntervalStep" : 2,
  16. "links" : {
  17. },
  18. "consolidationIntervalMsec" : 10000
  19. }

Hide execution results

Set a view property:

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

Show execution results

  1. {
  2. "cleanupIntervalStep" : 12,
  3. "commitIntervalMsec" : 1000,
  4. "consolidationIntervalMsec" : 10000,
  5. "consolidationPolicy" : {
  6. "type" : "tier",
  7. "segmentsBytesFloor" : 2097152,
  8. "segmentsBytesMax" : 5368709120,
  9. "segmentsMax" : 10,
  10. "segmentsMin" : 1,
  11. "minScore" : 0
  12. },
  13. "primarySort" : [ ],
  14. "writebufferActive" : 0,
  15. "writebufferIdle" : 64,
  16. "writebufferSizeMax" : 33554432,
  17. "links" : {
  18. }
  19. }

Hide execution results

Add a link:

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

Show execution results

  1. {
  2. "cleanupIntervalStep" : 12,
  3. "commitIntervalMsec" : 1000,
  4. "consolidationIntervalMsec" : 10000,
  5. "consolidationPolicy" : {
  6. "type" : "tier",
  7. "segmentsBytesFloor" : 2097152,
  8. "segmentsBytesMax" : 5368709120,
  9. "segmentsMax" : 10,
  10. "segmentsMin" : 1,
  11. "minScore" : 0
  12. },
  13. "primarySort" : [ ],
  14. "writebufferActive" : 0,
  15. "writebufferIdle" : 64,
  16. "writebufferSizeMax" : 33554432,
  17. "links" : {
  18. "colA" : {
  19. "analyzers" : [
  20. "identity"
  21. ],
  22. "fields" : {
  23. },
  24. "includeAllFields" : true,
  25. "storeValues" : "none",
  26. "trackListPositions" : false
  27. }
  28. }
  29. }

Hide execution results

Add another link:

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

Show execution results

  1. {
  2. "cleanupIntervalStep" : 12,
  3. "commitIntervalMsec" : 1000,
  4. "consolidationIntervalMsec" : 10000,
  5. "consolidationPolicy" : {
  6. "type" : "tier",
  7. "segmentsBytesFloor" : 2097152,
  8. "segmentsBytesMax" : 5368709120,
  9. "segmentsMax" : 10,
  10. "segmentsMin" : 1,
  11. "minScore" : 0
  12. },
  13. "primarySort" : [ ],
  14. "writebufferActive" : 0,
  15. "writebufferIdle" : 64,
  16. "writebufferSizeMax" : 33554432,
  17. "links" : {
  18. "colA" : {
  19. "analyzers" : [
  20. "identity"
  21. ],
  22. "fields" : {
  23. },
  24. "includeAllFields" : true,
  25. "storeValues" : "none",
  26. "trackListPositions" : false
  27. },
  28. "colB" : {
  29. "analyzers" : [
  30. "identity"
  31. ],
  32. "fields" : {
  33. "text" : {
  34. }
  35. },
  36. "includeAllFields" : false,
  37. "storeValues" : "none",
  38. "trackListPositions" : false
  39. }
  40. }
  41. }

Hide execution results

Remove the first link again:

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

Show execution results

  1. {
  2. "cleanupIntervalStep" : 12,
  3. "commitIntervalMsec" : 1000,
  4. "consolidationIntervalMsec" : 10000,
  5. "consolidationPolicy" : {
  6. "type" : "tier",
  7. "segmentsBytesFloor" : 2097152,
  8. "segmentsBytesMax" : 5368709120,
  9. "segmentsMax" : 10,
  10. "segmentsMin" : 1,
  11. "minScore" : 0
  12. },
  13. "primarySort" : [ ],
  14. "writebufferActive" : 0,
  15. "writebufferIdle" : 64,
  16. "writebufferSizeMax" : 33554432,
  17. "links" : {
  18. "colB" : {
  19. "analyzers" : [
  20. "identity"
  21. ],
  22. "fields" : {
  23. "text" : {
  24. }
  25. },
  26. "includeAllFields" : false,
  27. "storeValues" : "none",
  28. "trackListPositions" : false
  29. }
  30. }
  31. }

Hide execution results

Drop the view:

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

Show execution results

  1.  

Hide execution results