Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
modifying an array property in cypher
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mat Tyndall  
View profile  
 More options Jun 29 2012, 6:55 pm
From: Mat Tyndall <mat.tynd...@gmail.com>
Date: Fri, 29 Jun 2012 15:55:49 -0700 (PDT)
Local: Fri, Jun 29 2012 6:55 pm
Subject: modifying an array property in cypher

So I'm trying to check to see if a value exists in an array on a node and
then if it doesn't add it.

Example: check if 'c' is present in (node {array:['a','b']}) and if not add
it (node {array:['a','b','c']}).

I get the feeling with the various functions that I can iterate through the
array and use regular expressions to test each value but how do I then push
a new value into the array?

I'm pretty sure I could split it into 2 queries but one would be better.

I'm going to experiment in the console but if anybody has already solved
this problem I'd love to see.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mat Tyndall  
View profile  
 More options Jun 29 2012, 10:02 pm
From: Mat Tyndall <mat.tynd...@gmail.com>
Date: Fri, 29 Jun 2012 19:02:00 -0700 (PDT)
Subject: Re: modifying an array property in cypher

So turns out adding to an array is easy, "SET node.array = node.array +
value", however I can't figure out how to conditionally create the array
property if it doesn't exist without splitting this into 2 queries.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Hunger  
View profile  
 More options Jun 30 2012, 1:00 am
From: Michael Hunger <michael.hun...@neotechnology.com>
Date: Sat, 30 Jun 2012 06:00:49 +0100
Local: Sat, Jun 30 2012 1:00 am
Subject: Re: [Neo4j] Re: modifying an array property in cypher

Usually you should be able to do:

start node = ...
where {value} in node.array
set node.array = node.array + {value}

Please try this

Michael

Am 30.06.2012 um 03:02 schrieb Mat Tyndall:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mat Tyndall  
View profile  
 More options Jun 30 2012, 6:16 pm
From: Mat Tyndall <mat.tynd...@gmail.com>
Date: Sat, 30 Jun 2012 15:16:37 -0700 (PDT)
Local: Sat, Jun 30 2012 6:16 pm
Subject: Re: [Neo4j] Re: modifying an array property in cypher

that works, but if the array property hasn't been created yet it throws an
error.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Russell Duhon  
View profile  
 More options Jun 30 2012, 8:46 pm
From: Russell Duhon <fug...@gmail.com>
Date: Sat, 30 Jun 2012 17:46:43 -0700
Local: Sat, Jun 30 2012 8:46 pm
Subject: Re: [Neo4j] Re: modifying an array property in cypher

Hi,

First time posting on the list, but I've been doing some similar stuff.

You can deal with the not-yet-created problem with coalesce, eg

start node = ...
set node.array = coalesce(node.array?, []) + value

(Just tried it out on a reasonably recent milestone).

I hope that helps,
Russell


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Hunger  
View profile  
 More options Jul 1 2012, 3:13 am
From: Michael Hunger <michael.hun...@neotechnology.com>
Date: Sun, 1 Jul 2012 08:13:19 +0100
Local: Sun, Jul 1 2012 3:13 am
Subject: Re: [Neo4j] Re: modifying an array property in cypher

Thanks Russell, that's correct, I think we should add an example for this whole use-case to the manual.

Michael

Am 01.07.2012 um 01:46 schrieb Russell Duhon:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mat Tyndall  
View profile  
 More options Jul 2 2012, 5:19 am
From: Mat Tyndall <mat.tynd...@gmail.com>
Date: Mon, 2 Jul 2012 02:19:46 -0700 (PDT)
Local: Mon, Jul 2 2012 5:19 am
Subject: Re: [Neo4j] Re: modifying an array property in cypher

Awesome, thanks Russel and Michael! I knew I was missing a permutation.

And to round things out, to remove a value from an array I use the
following query:

SET node.array = filter(x in node.array : not(x=value))

And yeah, adding more of these sorts of queries to the examples would be
great.

-Mat


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »