AddEntity

Add a new entity of a specified class, and properties associated with the new entity.

Parameters

  • class: name of entity class.
  • [optional] _ref: reference to be used within the transaction.
  • blob: indicates whether a blob is expected in the array of blobs, that corresponds to the entity.

Blocks

Details

The properties are key-value pairs associated with the entity. Check properties for more details.

Using the constraints block in AddEntity makes it a “conditional add”. Check constraints for more details.

Examples

Add a “Person” using AddEntity command:

[ {
    "AddEntity" : {
        "class" : "Person",
        "properties" : {
            "name" : "Jane Doe",
            "gender": "F",
            "email": "jane.doe@xyz.com"
        }
    }
} ]

Conditionally add a “Person” if the email is not already registered:

[ {
    "AddEntity" : {
        "class" : "Person",
        "constraints" : {
            "email": [ "==", "jane.doe@xyz.com" ],
        },
        "properties" : {
            "name" : "Jane Doe",
            "gender": "F",
            "email":  "jane.doe@xyz.com"
        }
    }
} ]

Conditionally add a “Person” if the email is not already registered, add a “Visit” event, and create a connection between the “Person” and the “Visit”:

[ {
    "AddEntity" : {
        "class" : "Person",
        "_ref": 1,
        "constraints" : {
            "email": [ "==", "jane.doe@xyz.com" ],
        },
        "properties" : {
            "name" : "Jane Doe",
            "gender": "F",
            "email":  "jane.doe@xyz.com"
        }
    }
}, {
    "AddEntity" : {
        "class" : "Visit",
        "properties" : {
            "start": {"_date": "Mon Aug 7 10:59:24 PDT 2017"}
            "end":   {"_date": "Mon Aug 7 12:59:24 PDT 2017"}
        },
        "link": {
            "ref": 1,
            "class": "PersonMadeVisit",
        }
    }
} ]