0

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.

David Makogon
  • 69,407
  • 21
  • 141
  • 189
Mujassir Nasir
  • 1,640
  • 4
  • 31
  • 52

1 Answers1

2

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.

Jay Gong
  • 23,163
  • 2
  • 27
  • 32