Reputation: 837
This seems like a simple use case but I'm having trouble locating an example in the docs.
I want to do the following:
MERGE(node:Graph{id:{id}})
ON CREATE SET node.firstseen = timestamp(),
SET node.id = {id},
node.list = [list]
Examples of this would be appreciated, thanks!
Upvotes: 1
Views: 161
Reputation: 15086
You have a comma before your SET
clause:
ON CREATE SET node.firstseen = timestamp(),
^
The correct query is
MERGE (node:Graph {id:$id})
ON CREATE SET node.firstseen = timestamp()
SET
node.list = $list
You don't need to set the id
field, the MERGE
takes care of this. The list
field will be set every time you call the query, the firstseen
timestamp only when the node doesn't exist.
Upvotes: 1
Reputation: 67009
Assuming you pass id
and list
as parameters:
MERGE (node:Graph {id: $id})
ON CREATE SET
node.firstseen = timestamp(),
node.list = $list
You cannot have a SET
clause within another SET
clause. Besides, it is unnecessary to SET node.id = $id
anyway, since your MERGE
already guarantees that property has that value.
Upvotes: 1