Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-21-2019 09:01 PM
Hi again!
I was having issues trying to return multiple variables with the JS driver (returning both a & b in a single statement)
const drug = await session.run('MATCH (a:thing1 {id: $id})
MATCH (b:thing2 {id: $id}) CREATE (a)-[r:$rel {weight: $weight})->(b)
RETURN a, b'
If I return just one variable, the records.length correctly updates with however many "a" is, but if I try adding in another return variable (like a, b) it doesn't add it to the results.records with a. Would I just need another session.run statement to return the other variable, or is there something I'm missing?
Thanks 🙂
-Rachel
Solved! Go to Solution.
05-22-2019 12:53 PM
Hello,
The number of records is equal to the number of rows of results. When you have RETURN a, b
this adds b
as an additional column in the returned records, not as an additional record by itself.
Looking at the Neo4j from Javascript article, take a look at the last example:
var query="MATCH (n:User) RETURN n, labels(n) as l LIMIT {limit}"
var params={limit: 10}
var cb=function(err,data) { console.log(JSON.stringify(data)) }
cypher(query,params,cb)
{"results":[
{"columns":["n","l"],
"data":[
{"row":[{"name":"Aran"},["User"]]}
]
}],
"errors":[]}
The variables in the RETURN do not change the number of records returned, but they do change the columns returned and the associated row
results per record.
05-22-2019 12:53 PM
Hello,
The number of records is equal to the number of rows of results. When you have RETURN a, b
this adds b
as an additional column in the returned records, not as an additional record by itself.
Looking at the Neo4j from Javascript article, take a look at the last example:
var query="MATCH (n:User) RETURN n, labels(n) as l LIMIT {limit}"
var params={limit: 10}
var cb=function(err,data) { console.log(JSON.stringify(data)) }
cypher(query,params,cb)
{"results":[
{"columns":["n","l"],
"data":[
{"row":[{"name":"Aran"},["User"]]}
]
}],
"errors":[]}
The variables in the RETURN do not change the number of records returned, but they do change the columns returned and the associated row
results per record.
05-23-2019 12:02 PM
Oh ok got it, thank you!
All the sessions of the conference are now available online