Skip to content

Instantly share code, notes, and snippets.

@moonglum
Created November 25, 2014 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moonglum/21208befa3ce6227559d to your computer and use it in GitHub Desktop.
Save moonglum/21208befa3ce6227559d to your computer and use it in GitHub Desktop.
Short demonstration of using prefixed collections when using graph stuff in Foxx
var relationName = applicationContext.collectionName("containsX");
var vertexCollectionName = applicationContext.collectionName("X");
var graph_module = require("org/arangodb/general-graph");
var sampleGraph = graph_module._graph("sampleGraph");
var contactSpaceGraph = graph_module._graph("sampleGraph");
var vertex = contactSpaceGraph._getVertexCollectionByName(vertexCollectionName);
var edge = contactSpaceGraph._getEdgeCollectionByName(relationName);
var Foxx = require("org/arangodb/foxx");
var controller = new Foxx.Controller(applicationContext);
controller.get('/vars', function (req, res) {
res.json({
vertex: vertexCollectionName,
relation: relationName
});
});
{
"name": "graph",
"version": "0.0.1",
"description": "Testing Vikas Tandi's problem",
"author": "Lucas Dohmen",
"license": "Apache 2 License",
"controllers": {
"/graph": "graph.js"
},
"setup": "./setup.js"
}
var graph_module = require("org/arangodb/general-graph");
var graph = null;
if(!graph_module._exists("sampleGraph")) {
var relationName = applicationContext.collectionName("containsX");
var vertexCollectionName = applicationContext.collectionName("X");
var containsXRelation = graph_module._directedRelation(relationName, [vertexCollectionName], [vertexCollectionName]);
var edgeDefinitions = graph_module._edgeDefinitions(containsXRelation);
graph = graph_module._create("sampleGraph", edgeDefinitions);
} else {
graph = graph_module._graph("sampleGraph");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment