Created
November 25, 2014 09:37
-
-
Save moonglum/21208befa3ce6227559d to your computer and use it in GitHub Desktop.
Short demonstration of using prefixed collections when using graph stuff in Foxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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