UpdateEntity
Updates existing Entity objects that satisfy the specified constraints.
Parameters
- [optional] ref: Reference to other entities within the transaction.
- [optional] with_class: name of entity class.
- [optional] constraints
- [optional] properties
- [optional] remove_props
Details
If the ref parameter is specified, it must refers to the search results of a previous FindEntity.
For more complex searches for object to update, a Find command must be used first within the transaction.
Examples
Find the entity of class "Person" with a particular "email" property, and remove the "last_connected" property:
[{
"UpdateEntity": {
"with_class": "Person",
"constraints": {
"email": ["==", "jane.doe@xyz.com"]
},
"remove_props": ["last_connected"]
}
}]
Successful response:
[{
"UpdateEntity": {
"count": 1,
"status": 0
}
}]
Find the entity of class "Person" with a specific "email" property, and change/add two new properties:
[{
"UpdateEntity": {
"with_class": "Person",
"constraints": {
"email": ["==", "jane.doe@xyz.com"]
},
"properties": {
"type": "friend",
"year_met": 2018
}
}
}]
Successful response:
[{
"UpdateEntity": {
"count": 1,
"status": 0
}
}]
Update all entities of the class "Person" that have the property "age" greater than 18 and that have a connection to an entity of the class "Nation", setting their property "vaccine" to "eligible":
[{
"FindEntity": {
"with_class": "Nation",
"_ref": 1,
"constraints": {
"name": ["==", "India"]
}
}
}, {
"FindEntity": {
"_ref": 2,
"with_class": "Person",
"constraints": {
"age": [">=", 18]
},
"is_connected_to": {
"ref": 1
}
}
}, {
"UpdateEntity": {
"ref": 2,
"properties": {
"vaccine": "eligible"
}
}
}]
Successful response:
[{
"FindEntity": {
"returned": 0,
"status": 0
}
}, {
"FindEntity": {
"returned": 0,
"status": 0
}
}, {
"UpdateEntity": {
"count": 1,
"status": 0
}
}]