Reputation: 139
I have created vertex class Person and edge class friends. After insertion in class Person the query result returns @rid and some kind of other data or properties etc.
and I want to use this @rid for creating edges between vertices. I want to implement something like:
create edge friends
from (insert into person (name) values("John"))
to (insert into person (name) values("Ann"))
so that I should be able to create edge immediately in one query.
I am inserting batch data with prepared statement, that's why I can't get @rid after insertion, and because of that I want to make it in one query. I suppose it would be faster as well.
How to do that?
Upvotes: 2
Views: 323
Reputation: 2814
You can use batch scripts and LET statements:
LET $alice = insert into person (name) values("Alice");
LET $bob = insert into person (name) values("Bob");
LET $charlie = insert into person (name) values("Charlie");
create edge friends from $alice to $bob;
create edge friends from $bob to $charlie;
If you do it from Studio, make sure you select the BATCH mode.
Upvotes: 2