connect

connect creates connections between an object inserted by an Add* command and objects referenced earlier in the transaction.

Field contract

connect accepts one object or an array of objects. Each object creates connections to the objects identified by its reference.

Field

Type / required

Behavior

ref

integer / required

Required reference to objects selected or created earlier in the transaction.

class

string / required

Names the connection between the new object and each referenced object. These objects determine the endpoint classes and types.

direction

string / optional

Default out: source is the new object. in reverses the endpoints.

properties

object / optional

Omitted: no user properties on the new connections; uses the ordinary property-value rules.

Parameters

  • ref: Reference to other objects within the transaction.

  • [required] 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 in the Add command.

A connect object specifies the reference and connection direction:

# 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.

The following request creates two entities and a connection between them:

[{
    "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
    }
}]