Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-29-2021 02:53 PM
Neo4j server community 4.3.3 - Linux Ubuntu 20.04
Hi,
I wasn't able to answer the following question:
I have two nodes: a User and a Recipe, both have an uuid and a name.
I want to execute the following query:
MATCH (user:User {uuid: $UserUuid}
MATCH (recipe:Recipe {uuid: $recipeUuid}
OPTIONAL MATCH (recipe)<-[evaluation:IS_EVALUATING]-(user)
then I want to return just one new object, called newEvaluation
as in the following pseudocode:
return (user.uuid, user.name, recipe.uuid, recipe.name, evaluation.properties) as newEvaluation.
if there is no relationship, the evaluation.properties should be null.
I experimenting a lot, but I always got four text columns and a node, while I need the node to be splattered and everything should appear as a new node.
Any suggestion will be appreciated.
Thanks
Solved! Go to Solution.
09-30-2021 04:23 AM
You can return a map/dict/object by creating a literal map
MATCH (user:User {uuid: $UserUuid}
MATCH (recipe:Recipe {uuid: $recipeUuid}
OPTIONAL MATCH (recipe)<-[evaluation:IS_EVALUATING]-(user)
RETURN { userId: user.uuid, userName: user.name, recipeId: recipe.uuid, recipeTitle: recipe.name, evaluation: evaluation.properties } as result
09-30-2021 04:23 AM
You can return a map/dict/object by creating a literal map
MATCH (user:User {uuid: $UserUuid}
MATCH (recipe:Recipe {uuid: $recipeUuid}
OPTIONAL MATCH (recipe)<-[evaluation:IS_EVALUATING]-(user)
RETURN { userId: user.uuid, userName: user.name, recipeId: recipe.uuid, recipeTitle: recipe.name, evaluation: evaluation.properties } as result
All the sessions of the conference are now available online