gpt4 book ai didi

orientdb - 你如何使用orientjs做一个 'Insert if not exists'?

转载 作者:行者123 更新时间:2023-12-04 19:38:00 26 4
gpt4 key购买 nike

执行“如果不存在则插入”的惯用方法是什么?

这可以在没有事务的情况下完成吗?

最佳答案

尝试这个:

如果不存在,则使用 upsert 创建一条记录,除非它更新

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();

希望能帮助到你。

问候

关于orientdb - 你如何使用orientjs做一个 'Insert if not exists'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39213729/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com