OK title may be not clear, but here is the problem:
I have an array where the IDs of some main-equipment
data is stored. Each equipment entity has some child-equipment
with their subIDs.
I make an AJAX call to server to retrieve subIDs of each child-equipment
by looping the IDs of main-equipment
. Later I want to map the individual main-equipment
ID with its child-equipment
IDs and assign a relationship between them with Neo4j graph database. Following what I have came up:
for (var j in mainIDs) {
$.ajax({
type: "GET",
url: "https://someserver.com/api/v1/equipment/"+mainIDs[j]+"/childequipments",
dataType: "json",
cache: false
}).done(function (result) {
// get ID number of child equipments
var results = result.content;
for (var i = 0; i < results.length; i++) {
$.ajax({
type: "POST",
url: "http://localhost:7474/db/data/transaction/commit",
accepts: {json: "application/json"},
dataType: "json",
contentType: "application/json",
data: JSON.stringify({"statements": [{"statement": "START n=node(*), m=node(*) WHERE has (n.id) and has(m.id) and n.id ='"+mainIDs[j]+"' and m.id='"+results[i].id+"' MERGE (m)-[:BELONGS_TO]->(n)"}]}),
success: function(result) {
console.log('successful');
}
What I am in this query to reach sth similar like following logic:
Equipment 11 has child-equipment 20
Equipment 11 has child-equipment 21
Equipment 11 has child-equipment 22
Equipment 13 has child-equipment 40
Equipment 13 has child-equipment 41
But I get only one main-equipment
ID (usually first) with all child-equipment
ID instead of each of the main-equipment
ID. How can I reach the above result? Thanks.