Update and update for Vertex and Edge

Is there a way to create both Vertex and Edge in the same query?

I know that we can use out_EdgeName / in_EdgeName to update the edge of the vertex if it already exists in the UPDATE query, but how to do this to create a new edge and assign it to the vertex?

Usage example in the Upgrade Upsert request - Vertex is created, and we need to create a new Edge for this vertex. Can we do this in the same query, or will we need at least two queries (for example, 2 UPDATE - UPSERTS)?

Taking cue from edgedb sql updated :

Something like UPDATE Persons SET phone = 000000, out_Inside = (UPDATE Edge UPSERT, where in = @ some_rid / sub-query, out = $ this), where person_id = 8

+4
source share
1 answer

This question is relevant if you are using the new version of orientdb 2.1. But as far as I know, these functions were implemented in version 2.2.

"As far as I can tell, updates work (including to / from):"

UPDATE FRIEND SET in=#11:5 WHERE in.name="Samantha" and out.name="Mat"

Although using the query inside the set clause for in / out will result in an array return:

UPDATE Friend SET in=(SELECT FROM User WHERE name="Jason") WHERE in.name="Samantha" and out.name="Mat"

Upsert also works, although when creating a new vertex, it does not set the in / out properties. You can set the I / O properties yourself, for example:

UPDATE Friend SET comment="Wazzzaup", in=#11:5, out=#11:6 UPSERT WHERE in.name="Jason" AND out.name="Mat"

This will lead to a longer query when using the subquery for in = and out =, but at least it works (the subquery has the same problem as above).

I got this information from the release: https://github.com/orientechnologies/orientdb/issues/1114#issuecomment-156585776

0
source

All Articles