How to UNRELATE records #227
zecar
started this conversation in
Show and tell
Replies: 2 comments 3 replies
-
|
My immediate - but untested - thought would be DELETE gender WHERE <-interested_in<-user:"user_male"I am pretty sure there is a short version. Try something with the reverse traversal, I think that's the key. |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
This is what I come so far -- it works. --empty node
delete user;
delete fruit;
delete interested_in;-- create user
create user content {
username: 'user_male'
};
create user content {
username: "user_female"
};
select * from user;--create fruit
create fruit:apple;
create fruit:banana;
create fruit:cherry;
select * from fruit;--make relation
relate (select * from user where username = 'user_male')->interested_in->fruit:apple;
relate (select * from user where username = 'user_male')->interested_in->fruit:banana;
relate (select * from user where username = 'user_male')->interested_in->fruit:cherry;
relate (seleCT * from user where username ='user_female')->interested_in->fruit:banana;
select * from interested_in order by in;--user_male not interested in banana, remove it
delete interested_in where in inside (select id from user where username = 'user_male') and out = fruit:banana;
select * from interested_in; |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
let's say that user_male no longer likes women. In order to unrelate that, we can use something like this:
DELETE interested_in WHERE gender:female INSIDE ->gender AND count(array::distinct(array::concat(<-user, (SELECT id FROM user WHERE username = "user_male")))) = 1 RETURN BEFOREDo you guys have a better solution?
Beta Was this translation helpful? Give feedback.
All reactions