Thanks Alistair.

Your advice directed me to the Cypher refcard 
(http://docs.neo4j.org/refcard/2.0/) where I ended up finding the coalesce 
function which does exactly what I need:

SET r.passCount = coalesce(r.passCount, 0) +1

On Friday, February 7, 2014 4:04:37 PM UTC, Alistair Jones wrote:
>
> Hi Ben,
>
> Have you looked at MERGE?
> http://docs.neo4j.org/chunked/stable/query-merge.html
>
> -Alistair
>
>
>
> On 7 February 2014 15:58, Ben Titmarsh <[email protected] 
> <javascript:>>wrote:
>
>> Hello, 
>>
>> Is it possible to write a semantic Upsert, i.e. update or insert if it 
>> doesn't exist using one cypher query?
>>
>> To give a bit of context, this is what I'm doing:
>>
>> MATCH (fromCard:Card)-[r:DECK_INCIDENCE]-(toCard:Card) 
>> WHERE fromCard.name in {...} and toCard.name in {...}
>> SET r.passCount = r.passCount+1
>>
>> If the property passCount doesn't exist yet on the relationship then I'd 
>> like to set it to 1.
>>
>> Is it possible to achieve an upsert using one query?
>>
>> Cheers,
>> Ben.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Neo4j" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to