Skip to main content

AddEntity

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

Parameters

Details

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

if_not_found can be used to turn this command into "conditional add". Check if_not_found for more details.

connect can be used to create a connection between the added object and other object(s). Check connect for more details.

Examples

Add a "Person" using AddEntity command:


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

Successful response:


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

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


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

Expected response:


[{
"AddEntity": {
"status": 2,
"info": "Object Exists!"
}
}]

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": {
"_ref": 1,
"class": "Person",
"if_not_found": {
"email": ["==", "alice@xyz.com"]
},
"properties": {
"name": "Alice",
"gender": "F",
"email": "alice@xyz.com"
}
}
}, {
"AddEntity": {
"class": "Visit",
"properties": {
"start_year": {
"_date": "Mon Aug 7 10:59:24 PDT 2017"
},
"end_year": {
"_date": "Mon Aug 7 12:59:24 PDT 2017"
},
"billing_id": 123
},
"connect": {
"ref": 1,
"class": "PersonMadeVisit"
}
}
}]

Successful response:


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