简体   繁体   中英

How to insert data as JSON object with Gremlin API in Azure Cosmos DB

How to insert data as a JSON object in Gremlin

Currently, the following query is used to insert person object with some properties:

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

With the above approach, I have to call .property() method for each attribute and there could be more than 50 attributes in my object/class.

Is ther anyway to insert the complete object in one call

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

};

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

Please note that, I am using MS Cosmos DB Gremlin API with NodeJs.

No such method or api which is similar to your imagination could be found in gremlin api .

According to your description,it seems that you just want to bulk import multiple properties into Vertex.I'd recommand you to loop the property json array or json object( for key in obj.... ) to execute .property('XXX', 'YYY') in the bulk.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM