Remove or delete object instances
One may erase an instance from a collection by calling erase() or eraseCollection() . Both functions will definitively remove instances from the collection and all its indexes. When the collection is superset for one or more other collections, the instances are removed from all subsets, too.
When erasing a collection, one may set a filter before in order to erase instances fulfilling the filter condition, only.
It depends, however, from the collection definition, what is going to happen with the instance itself. When the collection is the owner of the instance, the instance will be deleted completely. This includes deleting all relationships to other instances or collections. The same happens, when the instance depends on the collection, i.e the collection is defined containing depending instances ( PropertyDefinition ::dependingInstances() ).
The application may also force deleting instances by passing the bDeleteInstance parameter as true .
... RemoveGrownUp ( Property &allChildren ) {
int pos = 0;
Value age(allChildren,"age");
allChildren.top();
while ( allChildren.tryGet(pos) )
if ( age >= 18 )
allChildren.erase(pos); // remove person from allChildren collection
else
pos++;
}
... RemoveGrownUp ( Property &allChildren ) {
allChildren.filter("age > = 18");
allChildren.eraseCollection();
}
When an instanbce to be removed depends on one of the subsets of the collection, the instance is deleted as well. When removing the inverse reference and the instance depends on the inverse reference, removing the instance from the collection fails.