Permalink
Browse files

Implemented get node by id functionality

  • Loading branch information...
DamonOehlman committed Jan 11, 2013
1 parent 614150d commit 650dac63be91980e5be34f3991e34895c2b6320e
Showing with 32 additions and 1 deletion.
  1. +32 −1 index.js
View
@@ -109,7 +109,13 @@ exports.activateType = function(graph, definition, callback) {
};
/**
-## createNode(data, callback)
+## createLink
+*/
+exports.createLink = function(graph, data, callback) {
+};
+
+/**
+## createNode(graph, data, callback)
*/
exports.createNode = function(graph, data, callback) {
var db = graph._db;
@@ -130,6 +136,31 @@ exports.createNode = function(graph, data, callback) {
db.createVertex(_.omit(data, 'type'), { 'class': data.type }, callback);
};
+/**
+## createEdge(graph, sourceId, targetId, data, callback)
+*/
+exports.createEdge = function(graph, sourceId, targetId, data, callback) {
+
+};
+
+/**
+## getNode(graph, id, nodeType, callback)
+*/
+exports.getNode = function(graph, id, nodeType, callback) {
+ var db = graph._db;
+
+ // if we don't have a db connection, abort the operation
+ if (! db) return callback(errors.NOT_CONNECTED);
+
+ // look for the node details
+ db.command(
+ 'SELECT FROM ' + (nodeType || 'V') + ' WHERE id = "' + id + '"',
+ function(err, results) {
+ callback(err, (results || [])[0]);
+ }
+ );
+};
+
/**
## series(commands, targetDb, callback)

0 comments on commit 650dac6

Please sign in to comment.