addV

Synopsis

g.addV('<vertexLabel>').
  property ('<property_key>', <property_value>) ...

Description

Vertex data is inserted using addV, a TinkerPop step. A previously created hvertex label is required along with the properties that define the partition key. Additional properties can be inserted with the required properties.

Property keys and value types must be defined in the schema for vertex labels. Using property, a valid data type value must be inserted. Some data types require special handling in entering the property value:

  • Date and Time: Strings with quotes and either as LocalDate or as LocalTime, respectively.

  • All collections (Set, List, Map): Square brackets around quoted entries, followed by as Set for sets and as Map for maps. Lists only require square brackets.

  • Tuple: Square brackets around quoted entries, as Tuple after the tuple, enclosed in a second set of square brackets.

  • Geospatial properties will require as Point, as LineString, or as Polygon.

  • UUID: String with quotes and as UUID.

Examples

Create a vertex with a vertex label person with the partition key person_id and properties name, gender, nickname, and country:

g.addV('person').
   property('person_id', 'adb8744c-d015-4d78-918a-d7f062c59e8f' as UUID).
   property('name', 'Simone BECK').
   property('gender','F').
   property('nickname', ['Simca', 'Simone'] as Set).
   property('country', [['France', '1904-07-07' as LocalDate, '1991-12-20' as LocalDate] as Tuple])

Carefully study the use of special formatting for items like UUID, where as UUID must be included to convert the string to a UUID on insertion.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com