如何在Azure Cosmos DB中使用Gremlin API将数据作为JSON对象插入

问题描述 投票:0回答:1

如何在Gremlin中将数据作为JSON对象插入

当前,以下查询用于插入具有某些属性的人员对象:

g.addV('person').property('firstName', 'Thomas').property('lastName', 'Andersen').property('age', 44).property('userid', 101)

使用上述方法,我必须为每个属性调用.property()方法,并且我的对象/类中可能有50个以上的属性。

无论如何还是要在一个调用中插入完整的对象

var personData = {
    firstName: 'Thomas',
    lastName: 'Andersen',
    age: 44,
    userid: 101

};

g.addV('person', personData);
// OR
g.addV('person').data(personData);

[请注意,我将MS Cosmos DB Gremlin API与NodeJ一起使用。

node.js azure-cosmosdb gremlin cosmos azure-cosmosdb-gremlinapi
1个回答
0
投票

gremlin api中找不到与您的想像相似的方法或api。

根据您的描述,似乎您只是想将多个属性批量导入到Vertex中。我建议您循环遍历属性json数组或json对象(for key in obj....)以批量执行.property('XXX', 'YYY')。] >

© www.soinside.com 2019 - 2024. All rights reserved.