What is the idiomatic way for doing an 'insert if not exists'?
Can this be done without transactions?
Try this:
with upsert creates a record if it doesn't exists, unless it updates
var OrientDB = require('orientjs');
var server = OrientDB({
host: 'localhost',
port: 2424,
username: 'root',
password: 'root'
});
var db = server.use({
name: 'GratefulDeadConcerts',
username: 'root',
password: 'root'
})
db.query('UPDATE V SET id = 23 UPSERT WHERE id = 23')
.then(function (response) {
console.log(response);
});
server.close();
Hope it helps.
Regards
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With