gpt4 book ai didi

orientdb - orientjs - 如何执行批量插入

转载 作者:行者123 更新时间:2023-12-02 01:27:30 25 4
gpt4 key购买 nike

orientdb.insert()
.into('User')
.set({name: 'John', surname: 'Smith'})
.all()
.then(function(result) {
...
}, function(error){
...
})

这是通过orientjs在OrientDb中插入单个顶点的方法。如何一次插入多个对象?

下面的查询

orientdb.insert()
.into('User')
.set([{name: 'John', surname: 'Smith'}, {name: 'Harry', surname: 'Potter'}])
.all()
.then(function(result) {
...
}, function(error){
...
})

仅插入最后一个元素({name: 'Harry', surname: 'Potter'})

最佳答案

试试这个

var OrientDB = require('orientjs');

var server = OrientDB({
host: 'localhost',
port: 2424,
username: 'root',
password: 'root'
})

var db = server.use({
name: 'mydb',
username: 'admin',
password: 'admin'
})

db.query('insert into User2(name) values ("John"),("Harry")').then(function (response) {
console.log(response);
});

server.close();

这是我得到的结果

enter image description here

希望对你有帮助

关于orientdb - orientjs - 如何执行批量插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36178853/

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