Best Practises
Creating and deleting object hierarchies
2 min
let's assume you want to create grandfather, father and grandchild in a "person" entity to fill the "father" property for the grandchild, you need the dataid of the father record you can now first save the father using a save, use the returned guid to create the father with the next save call, and so on in one step , you do this using a saveall if no entry with the dataid passed in as a parameter exists yet, a new record is created! this also works to create a dependent record in this one query! example entity "person" with the entityid ff5f6566 d02c 4040 9016 cd222aaff0ee has a property custom 001 name and a property custom 002 father for the sake of clarity, we store the relationship as text in the names we use random, newly generated values as dataids this works in various programming languages, for example, like this c# guid newguid(); java uuid newguid = java util uuid randomuuid(); php $newguid = uniqid(); typescript const newguid = uuidv4(); { 	"items" \[ 	 { 	 "entityid" "ff5f6566 d02c 4040 9016 cd222aaff0ee", "dataid" "af92a7a0 e6a2 4237 a33c 5a87dd444fad" "custom 001" "großvater" 	 } ,{ 	 "entityid" "ff5f6566 d02c 4040 9016 cd222aaff0ee", "dataid" "4e609b9b 37c4 43aa 86ce 67e8377e8afa" "custom 001" "vater", "custom 002" "af92a7a0 e6a2 4237 a33c 5a87dd444fad", 	 	 } 	 ,{ 	 "entityid" "ff5f6566 d02c 4040 9016 cd222aaff0ee", "dataid" "af92a7a0 e6a2 4237 a33c 5a87dd444fad" 	 "custom 001" "enkel", "custom 002" "4e609b9b 37c4 43aa 86ce 67e8377e8afa" 	 } 	] } this entire hierarchy can also be deleted using a saveall, in which all entries are set to " isactive" = 0 the presence of a "child" may prevent the deletion of a "father" in this case, the order of the records must be reversed the child is at the top, the grandfather at the bottom { 	"items" \[ 	 { 	 "entityid" "ff5f6566 d02c 4040 9016 cd222aaff0ee", "dataid" "af92a7a0 e6a2 4237 a33c 5a87dd444fad" 	 "isactive" 0, 	 }, 	 { 	 "entityid" "ff5f6566 d02c 4040 9016 cd222aaff0ee", "dataid" "4e609b9b 37c4 43aa 86ce 67e8377e8afa" "isactive" 0, 	 }, 	 { 	 "entityid" "ff5f6566 d02c 4040 9016 cd222aaff0ee", "dataid" "af92a7a0 e6a2 4237 a33c 5a87dd444fad" "isactive" 0, 	 } 	] }