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
Message from discussion Cypher questions - return updates count, update 2 things in a single query
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
 
Wujek Srujek  
View profile  
 More options Oct 15 2012, 4:56 am
From: Wujek Srujek <wujek.sru...@gmail.com>
Date: Mon, 15 Oct 2012 10:56:30 +0200
Local: Mon, Oct 15 2012 4:56 am
Subject: Cypher questions - return updates count, update 2 things in a single query

Hi. I have the following structure:
NodeA has relationships to multiple NodeB; the relationships have a
property called 'preferred', which takes boolean values. I need to be able
to atomically change the preferred NodeB. I am doing this with Cypher on
version 1.8.
What I have now is two queries which look like this:

// reset the currently preferred, if any
start me = node({me}) match me-[r:LIKES]->t set r.preferred = false where
r.preferred = true // this might result in no relationships changed, that's
Ok - no preference yet
// set the new preferred
start me = node({me}), t = node({t}) match me-[r:LIKES]->t set r.preferred
= true

(Parameters 'me' and 't' are Nodes that I already have and don't have to
look up.)

This will be done in a single transaction so that it is atomic. However, I
have a couple of questions:

1. Is it possible to do such a thing in a single query? Is this practical?
Is it better to issue 2 simpler queries than 1 complex?
2. I would like to learn if the second query actually changed any
relationship. This is for error checking - node 't' in the second query
might not be related to 'me' at all, in which case the query would change 0
relationships. I think the easiest way for me would be to check the count
of changed relationships if I could return that, and if it is 0, node 't'
was unrelated to 'me'. How can I express this in Cypher?

Regards,
wujek


 
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.