charlie_pl
charlie_pl

Reputation: 3094

OrientDB - Create Edges if not exist with subselect

I have a unique constraint on edge:

CREATE CLASS hasAssignee extends E
CREATE PROPERTY hasAssignee.out LINK Assignable
CREATE PROPERTY hasAssignee.in LINK User
CREATE INDEX UniqueHasAssignee ON hasAssignee(out,in) UNIQUE

I want to multiple create edges if they don't yet exist in one query. If they do exist, then either replace them, or simply don't add them. Something like that, but without possibility of errors:

CREATE EDGE hasAssignee FROM ( SELECT FROM Project WHERE id=:id ) TO ( SELECT FROM User WHERE login in :login )

UPSERT from what I've noticed can deal with only one edge at a time (at least I couldn't produce query parsable by studio)

I see a few possibe solutions (but I don't see anything like it in docs):

  1. something like CREATE IFNOTEXISTS
  2. Soft indexes, that don't throw an error, simply don't create additional edges
  3. Remove unique index, create duplicates, and somehow remove duplicates after each query (?)

Is it possible to do something like that in orientdb? Should I fill out a request?

Upvotes: 2

Views: 716

Answers (1)

Luigi Dell'Aquila
Luigi Dell'Aquila

Reputation: 2814

There is an open feature request for this:

https://github.com/orientechnologies/orientdb/issues/4436

My suggestion is to vote on it

Upvotes: 2

Related Questions