edgeLabel
How to create an edge label.
Synopsis
schema.edgeLabel('edgeLabel').
[ single() | multiple() ].
[ properties(property[, property]).[ add() | drop() ] ].
[ connection( outVertex, inVertex) ].
[ ttl ].
[ ifNotExists() ].
[ create() | add() | drop() | describe() | exists() ]
Description
An edge label specifies a type of edge that can be stored in DSE Graph. An edge label can have cardinality specified (default is multiple), properties that an edge has defined, the connections that are defined between two types of vertices, and a time-to-live (TTL) to determine the lifecycle of an edge. The order that the options are added to the schema statement matter: cardinality, properties associated with the edge label, then connection.
- single, multiple
-
Specify whether an edge label can have a single edge or multiple edges between the specified vertices.
- properties
- Properties can be added to vertices and edges. A property key must be created prior to adding it to either type of element. Allowed characters for the name are alphabetical or underscore.
- connection
-
Set the two vertex labels that the edge label will connect.
- ttl
-
Set a time-to-live for an edge label.
- ifNotExists
- Creating an edge label can check for lack of current existence with
ifNotExists()before creating a new edge label.
Examples
made:schema.edgeLabel('made').create()included_in if the edge label doesn't already
exist:schema.edgeLabel('included_in').ifNotExists().create()schema.edgeLabel('reviewed').multiple().create()schema.edgeLabel('reviewed').properties('stars',time').add()isA specifying that the outgoing vertex label is
ingredient and the incoming vertex label is
fridge_item.schema.edgeLabel('isA').connection('ingredient', 'fridge_item).create()person and person specifying the edgeLabel
knows.schema.edgeLabel('knows').connection('person', 'person').add()schema.edgeLabel('reviewed').multiple().ifNotExists().create()
schema.edgeLabel('reviewed').properties('time','year','stars','comment').add()
schema.edgeLabel('reviewed').connection('person','recipe').add()Note
that the connection and the properties cannot be both specified during edge label creation.
A best practice is to create the edge label, then add the properties and the connection.schema.edgeLabel('gets').ttl(60).create(schema.edgeLabel('reviewed').exists()describe()
command:schema.edgeLabel('created').describe()drop()
command:schema.edgeLabel('made').drop()make_date from an edge label:
schema.edgeLabel('made').properties('make_date').drop()