Introduction: I am a newbie to Neo4jClient so forgive me if i ask something that has been asked before. But i have been stuck on this forever.
What i Am trying to do: I am trying to connect Neo4j with Keylines using .NET.
Cause: First, i used Neo4j's REST with Jquery AJAX to do Return (*) which returned everything including data and URI's of self, start, end, all_Relationships etc.
data: Object
end: "http://localhost:7474/db/data/node/93"
extensions: Object
metadata: Object
properties: "http://localhost:7474/db/data/relationship/4019/properties"
property: "http://localhost:7474/db/data/relationship/4019/properties/{key}"
self: "http://localhost:7474/db/data/relationship/4019"
start: "http://localhost:7474/db/data/node/6"
type: "SENT"
Hence i was able to use self as a ID for keylines Node and start and end URI's as Keyline's Link id1 and id2.
function queryNeo4j(query) {
var request = $.ajax({
type: "POST",
url: "http://localhost:7474/db/data/cypher",
contentType: "application/json",
data: JSON.stringify({ "query": query, "params": {} }),
success: afterQueryNeo4j
});
};
function afterQueryNeo4j(json) {
console.log(json); // returned data from ajax call
makeNodes(json);
makeLinks(json);
//console.log(items);
createKeylines(items);
};
// populates global var itmes with nodes
function makeNodes(param) {
for (i = 0; i < param.data.length ; i++) {
for (j = 0 ; j < 2 ; j++) {
var node = {
type: 'node',
id: param.data[i][j].self,
dt: stringToDateConverter(String(param.data[i][1].data.yyyyMMdd)),
b: 'rgb(100,255,0)',
c: 'rgb(0,0,255)',
t: param.data[i][j].data.name,
subject: param.data[i][j].data.subject
};
items.push(node);
}
}
};
// populates global var itmes with nodes
function makeLinks(json) {
for (i = 0; i < json.data.length; i++) {
var link = {
type: 'link',
id: json.data[i][2].self,
id1: json.data[i][2].start,
id2: json.data[i][2].end,
t: json.data[i][2].metadata.type,
w: 2,
c: 'rgb(0,0,255)'
}
items.push(link);
}
}
Using this technique i was successfully able to plot keylines graph and timebar using only client side Javascript. but problem Arose when i published this on IIS, it gave me Cross-Domain error which means i had to call Neo4j from server code (C#) and feed it to client side HTML/JS. That's when i found out about Neo4jClient.
Done so Far: I am Successfully able to read data from Neo4j in my C# code using
public class Person
{
public string name { get; set; }
public int dob { get; set; }
}
var query = client.cypher
.match(("person:Person"))
.return(person => person.As<Person>());
var result = query.results;
foreach (var i in result)
{
Console.WriteLine("people name is:"+i.name);
}
Problem: Now, i can read only data based on my Cypher Query but can't read other stuff like id, self, start, end URI's and relationships which i need for my UI.
Is there a way to get the Return (*) and all the other meta data using neo4jclient? Any code will help. Should i stick to Client side ajax call by resolving cross reference errors using JSONP or CORS since it was much easier but i am afraid that it might give me some problems down the line as it is not the proper way to do it?
I can't seem to find any proper documentation for Neo4jClient. There are so many options i see for return in Intellisense but dont't know how i can use them. Any help is greatly appreciated. Thanks in advance.