What is the correct way to create a new record only if it doesn’t already exist, in ODB (2.2.x or 3.0.x)? Specifically, I’m using the OrientJS
query function to build a SQL query.
I know that doing a read (to test for the existence of the record) followed by a conditional INSERT (or CREATE VERTEX) can be used, but based on my experience with other databases, I’m cautious that this will not be atomic under high load conditions.
In other SQL database implementations, there are options such as INSERTs that support a WHERE clause or the MSSQL MERGE operation, which allow for a bulletproof atomic way to do this, even under high load. But these options don’t exist in ODB.
Note that this is somewhat the inverse of the very useful (although not in this case) ODB UPSERT operation.