Skip to main content

connect

connect can be used to create a connection between objects (when present in an Add* command).

Parameters

  • ref: Reference to other objects within the transaction.
  • [optional] class: Name of the class that is used to describe the relationship between the objects.
  • [optional] direction: [in, out]. Default is "out. "in" indicates that the relationship actually ends at the object (object) in the Add*.

Here is an example of an isolated connect:

# Isolated connect parameter
"connect": {
"ref": 1234, # Reference to the result of another command
"class": "Visit", # Class name for the connection
"direction": "out" # Direction of the connection
}

connect indicates parameters of a connection that will be created between the added object and an object (or objects) referenced by the ref parameter.

For instance, we can create a connection between newly inserted entities as follows:

[{
"AddEntity": {
"class": "Person",
"_ref": 42,
"properties": {
"name": "Jane Doe",
"age": 20,
"gender": "F",
"email": "jane.doe@jupiter.pla"
}
}
}, {
"AddEntity": {
"class": "Person",
"properties": {
"name": "Jon Doe",
"age": 18,
"gender": "M",
"email": "jon.doe@mars.pla"
},
"connect": {
"class": "BestFriendForever",
"ref": 42
}
}
}]

Response:

[{
"AddEntity": {
"status": 0
}
}, {
"AddEntity": {
"status": 0
}
}]