Deleting from a relation¶
This operation deletes child objects from a parent in a relationship. The operation does not delete the actual objects, neither it deletes the relationship column. The operation simply disconnects the child objects from the parent.
Specific Children¶
There are multiple "flavors" of this operation, but in its core, it must reference a parent object and one or more child objects. The parent object must have a valid objectId
value. The APIs are grouped below by how the parent object is identified - using objectId
, as a map, as an instance of a custom class or as a result of a previous operation in the same transaction:
// Break the relation between the objects identified with objectId values in the
// childrenObjectId array and the parent object identified with parentObjectId.
// The parent object must be in the table with the parentTableName name.
// The relationship column between the parent and child objects is columnName.
// In other words, disconnect the child objects from the parent object for the
// relationship identified by columnName.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentTableName:(NSString * _Nonnull)
parentObjectId:(NSString * _Nonnull)
columnName:(NSString * _Nonnull)
childrenObjectIds:(NSArray<NSString *> * _Nonnull)];
// Same as the above with the only difference is the child objects are instances
// of a custom class (YourCustomClassForChild). It is important that
// YourCustomClassForChild matches the child table name. For example, if the
// relationship is between tables Person and Address, then the
// YourCustomClassForChild class must be "Address".
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentTableName:(NSString * _Nonnull)
parentObjectId:(NSString * _Nonnull)
columnName:(NSString * _Nonnull)
customChildren:(NSArray<YourCustomClassForChild *> * _Nonnull)];
// Same as the first signature above with the only difference is the child
// objects are instances of the Map interface. It is important that each Map object
// has a key/value pair for the "objectId" property with a valid value.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentTableName:(NSString * _Nonnull)
parentObjectId:(NSString * _Nonnull)
columnName:(NSString * _Nonnull)
children:(NSArray<NSDictionary<NSString *,id> *> * _Nonnull)];
// Break the relation between the objects represented by the "children" argument
// and the parent object. The parent object is identified by its objectId with the
// parentObjectId argument. The parent object must be stored in a table with the
// parentTableName name. The "children" argument is a result of a previous operation
// in the same transaction. It must represent either a collection of string values
// (objectIds) or a collection of objects. This is possible with the following
// previous operations:
// - Retrieving objects from the database
// - Saving multiple objects in the database
// It is important that all child objects referenced by the children argument exist
// in the child table that columnName points to.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentTableName:(NSString * _Nonnull)
parentObjectId:(NSString * _Nonnull)
columnName:(NSString * _Nonnull)
childrenResult:(OpResult * _Nonnull)];
// Break the relationship between the objects from the childrenObjectId array
// and the parentObject. The array must contain objectId values of the child
// objects. The parent object must be in the table with the parentTableName
// name. The relationship column between the parent and child objects is
// columnName. In other words, for the relationship represented through the
// columnName column, disconnect the child objects from the parent object.
// The parent object is a map of key/value pairs. One of the pairs must be
// objectId with the corresponding value. The children are identified with
// their objectId values.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentTableName:(NSString * _Nonnull)
parentObject:(NSDictionary<NSString *,id> * _Nonnull)
columnName:(NSString * _Nonnull)
childrenObjectIds:(NSArray<NSString *> * _Nonnull)];
// Same as the above with the only difference is the child objects are instances
// of a custom class (YourCustomClassForChild). It is important that
// YourCustomClassForChild matches the child table name. For example, if the
// relationship is between tables Person and Address, then the
// YourCustomClassForChild class must be "Address".
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentTableName:(NSString * _Nonnull)
parentObject:(NSDictionary<NSString *,id> * _Nonnull)
columnName:(NSString * _Nonnull)
customChildren:(NSArray<YourCustomClassForChild *> * _Nonnull)];
// Same as the first signature above with the only difference is the child
// objects are instances of the Map interface. It is important that each Map
// object has a key/value pair for the "objectId" property with a valid value.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentTableName:(NSString * _Nonnull)
parentObject:(NSDictionary<NSString *,id> * _Nonnull)
columnName:(NSString * _Nonnull)
children:(NSArray<NSDictionary<NSString *,id> *> * _Nonnull)];
// Break the relationship between the objects represented by the "children"
// argument and the parent object. The parent object is identified by a Map
// object which must have a key/value pair for the objectId property. The
// parent object must be stored in a table with the parentTableName name.
// The "children" argument is a result of a previous operation in the same
// transaction. It must represent either a collection of string values
// (objectIds) or a collection of objects. This is possible with the following
// previous operations:
// - Retrieving objects from the database
// - Saving multiple objects in the database
// It is important that all child objects referenced by the children argument
// exist in the child table that columnName points to.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentTableName:(NSString * _Nonnull)
parentObject:(NSDictionary<NSString *,id> * _Nonnull)
columnName:(NSString * _Nonnull)
childrenResult:(OpResult * _Nonnull)];
// Disconnect the objects identified with objectId values in the
// childrenObjectId array from parentObject for a relationship column
// with the name of columnName. Notice the parent object is an instance
// of YourCustomClassForParent. The class must declare public get/set
// methods for the objectId property or have a public objectId field.
// The child objects are identified with their objectId values. It is
// important that YourCustomClassForParent class matches the parent
// table name. Since the parent object is an instance of
// YourCustomClassForParent, it means the parent table where the
// parent object is stored must match the name of the class.
// For example, if YourCustomClassForParent is "Person", it means
// Backendless wiil:
// 1. Look for the parent object in the Person table
// 2. Locate a column with the columnName name in the Person table
// 3. Using the column definition, Backendless will identify the child table
// 4. Backendless will retrieve the child objects from the child table using
// the provided objectId values.
// 5. Backendless will disconnect the child objects from the relationship
// with the parent object.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentObject:(YourCustomClassForParent * _Nonnull)
columnName:(NSString * _Nonnull)
childrenObjectIds:(NSArray<NSString *> * _Nonnull)];
// Same as the above with the only difference is the child objects are
// represented through a custom class. It is important that
// YourCustomClassForChild matches the child table name. For example,
// if the relationship is between tables Person and Address, then the
// YourCustomClassForChild class must be "Address".
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentObject:(YourCustomClassForParent * _Nonnull)
columnName:(NSString * _Nonnull)
customChildren:(NSArray<YourCustomClassForChild *> * _Nonnull)];
// Same as the first signature above with the only difference is the child
// objects are instances of the Map interface. It is important that each
// Map object has a key/value pair for the "objectId" property with a
// valid value.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentObject:(YourCustomClassForParent * _Nonnull)
columnName:(NSString * _Nonnull)
children:(NSArray<NSDictionary<NSString *,id> *> * _Nonnull)];
// Same as the first signature above with the only difference is the children
// argument is a result of a previous operation in the same transaction. It
// must represent either a collection of string values (objectIds) or a
// collection of objects. This is possible with the following previous
// operations:
// - Retrieving objects from the database
// - Saving multiple objects in the database
// It is important that all child objects referenced by the children argument
// exist in the child table that columnName points to.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentObject:(YourCustomClassForParent * _Nonnull)
columnName:(NSString * _Nonnull)
childrenResult:(OpResult * _Nonnull)];
// Disconnect the children identified with their objectId values in the
// childrenObjectId array from parentObject for the relationship identified
// by the column with the name of columnName. The parentObject value is a
// result of a previous operation in the same transaction. These
// operations can be:
// - Saving a single object in the database
// - Updating a single object in the database
// The relationship column must be declared in the same table where
// parentObject comes from. It is important that all child objects in the
// childrenObjectId array exists in the child table that columnName points to.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentResult:(OpResult * _Nonnull)
columnName:(NSString * _Nonnull)
childrenObjectIds:(NSArray<NSString *> * _Nonnull)];
// Same as the above with the difference that the child objects are instances
// of the YourCustomClassForChildren class. The class used for child objects
// must match the name of the child table. Suppose the relationship is
// between tables Person and Address. In this case, the name of the class
// must be Address.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentResult:(OpResult * _Nonnull)
columnName:(NSString * _Nonnull)
customChildren:(NSArray<YourCustomClassForChildren *> * _Nonnull)];
// Same as the first signature above with the only difference is the child
// objects are instances of the Map interface. It is important that each Map
// object has a key/value pair for the "objectId" property with a valid value.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentResult:(OpResult * _Nonnull)
columnName:(NSString * _Nonnull)
children:(NSArray<NSDictionary<NSString *,id> *> * _Nonnull)];
// In this operation both the parent and the children objects are results of
// two separate previous operations in the same transaction. The parent
// object must be a result of any of the following operations:
// - Saving a single object in the database
// - Updating a single object in the database
// The relationship is identified through the column with the name in the
// columnName argument. The column must be declared in the same table where
// parentObject comes from. The children argument can be a result of the
// following operations:
// - Retrieving objects from the database
// - Saving multiple objects in the database
// It is important that all child objects referenced by the children argument
// exist in the child table that columnName points to.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentResult:(OpResult * _Nonnull)
columnName:(NSString * _Nonnull)
childrenResult:(OpResult * _Nonnull)];
// This method and the ones listed below identify the parent object the
// same way - using the OpResultValueReference class. This is a special
// class which references an object within a result of another operation
// within the same transaction. For example, a result of another operation
// can be a collection of objects. That collection can be returned from
// either the "Retrieving objects" or "Saving multiple objects" operations.
// All transaction operations return an OpResult object. Using the OpResult
// API you can obtain a single object which can be used as parent in the
// operations listed below. When a single object from a collection represented
// by OpResult is referenced, it is represented by the OpResultValueReference
// class.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentValueReference:(OpResultValueReference * _Nonnull)
columnName:(NSString * _Nonnull)
childrenObjectIds:(NSArray<NSString *> * _Nonnull)];
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentValueReference:(OpResultValueReference * _Nonnull)
columnName:(NSString * _Nonnull)
customChildren:(NSArray<YourCustomClassForChildren *> * _Nonnull)];
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentValueReference:(OpResultValueReference * _Nonnull)
columnName:(NSString * _Nonnull)
children:(NSArray<NSDictionary<NSString *,id> *> * _Nonnull)];
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentValueReference:(OpResultValueReference * _Nonnull)
columnName:(NSString * _Nonnull)
children:(NSArray<NSDictionary<NSString *,id> *> * _Nonnull)];
// Break the relation between the objects identified with objectId values in the
// childrenObjectId array and the parent object identified with parentObjectId.
// The parent object must be in the table with the parentTableName name.
// The relationship column between the parent and child objects is columnName.
// In other words, disconnect the child objects from the parent object for the
// relationship identified by columnName.
unitOfWorkInstance.deleteRelation(parentTableName: String,
parentObjectId: String,
columnName: String,
childrenObjectIds: [String]) -> OpResult
// Same as the above with the only difference is the child objects are instances
// of a custom class (YourCustomClassForChild). It is important that
// YourCustomClassForChild matches the child table name. For example, if the
// relationship is between tables Person and Address, then the
// YourCustomClassForChild class must be "Address".
unitOfWorkInstance.deleteRelation(parentTableName: String,
parentObjectId: String,
columnName: String,
customChildren: [YourCustomClassForChild]) -> OpResult
// Same as the first signature above with the only difference is the child
// objects are instances of the Map interface. It is important that each Map object
// has a key/value pair for the "objectId" property with a valid value.
unitOfWorkInstance.deleteRelation(parentTableName: String,
parentObjectId: String,
columnName: String,
children: [[String : Any]]) -> OpResult
// Break the relation between the objects represented by the "children" argument
// and the parent object. The parent object is identified by its objectId with the
// parentObjectId argument. The parent object must be stored in a table with the
// parentTableName name. The "children" argument is a result of a previous operation
// in the same transaction. It must represent either a collection of string values
// (objectIds) or a collection of objects. This is possible with the following
// previous operations:
// - Retrieving objects from the database
// - Saving multiple objects in the database
// It is important that all child objects referenced by the children argument exist
// in the child table that columnName points to.
unitOfWorkInstance.deleteRelation(parentTableName: String,
parentObjectId: String,
columnName: String,
childrenResult: OpResult) -> OpResult
// Break the relationship between the objects from the childrenObjectId array
// and the parentObject. The array must contain objectId values of the child
// objects. The parent object must be in the table with the parentTableName
// name. The relationship column between the parent and child objects is
// columnName. In other words, for the relationship represented through the
// columnName column, disconnect the child objects from the parent object.
// The parent object is a map of key/value pairs. One of the pairs must be
// objectId with the corresponding value. The children are identified with
// their objectId values.
unitOfWorkInstance.deleteRelation(parentTableName: String,
parentObject: [String : Any],
columnName: String,
childrenObjectIds: [String]) -> OpResult
// Same as the above with the only difference is the child objects are instances
// of a custom class (YourCustomClassForChild). It is important that
// YourCustomClassForChild matches the child table name. For example, if the
// relationship is between tables Person and Address, then the
// YourCustomClassForChild class must be "Address".
unitOfWorkInstance.deleteRelation(parentTableName: String,
parentObject: [String : Any],
columnName: String,
customChildren: [YourCustomClassForChild]) -> OpResult
// Same as the first signature above with the only difference is the child
// objects are instances of the Map interface. It is important that each Map
// object has a key/value pair for the "objectId" property with a valid value.
unitOfWorkInstance.deleteRelation(parentTableName: String,
parentObject: [String : Any],
columnName: String,
children: [[String : Any]]) -> OpResult
// Break the relationship between the objects represented by the "children"
// argument and the parent object. The parent object is identified by a Map
// object which must have a key/value pair for the objectId property. The
// parent object must be stored in a table with the parentTableName name.
// The "children" argument is a result of a previous operation in the same
// transaction. It must represent either a collection of string values
// (objectIds) or a collection of objects. This is possible with the following
// previous operations:
// - Retrieving objects from the database
// - Saving multiple objects in the database
// It is important that all child objects referenced by the children argument
// exist in the child table that columnName points to.
unitOfWorkInstance.deleteRelation(parentTableName: String,
parentObject: [String : Any],
columnName: String,
childrenResult: OpResult) -> OpResult
// Disconnect the objects identified with objectId values in the
// childrenObjectId array from parentObject for a relationship column
// with the name of columnName. Notice the parent object is an instance
// of YourCustomClassForParent. The class must declare public get/set
// methods for the objectId property or have a public objectId field.
// The child objects are identified with their objectId values. It is
// important that YourCustomClassForParent class matches the parent
// table name. Since the parent object is an instance of
// YourCustomClassForParent, it means the parent table where the
// parent object is stored must match the name of the class.
// For example, if YourCustomClassForParent is "Person", it means
// Backendless wiil:
// 1. Look for the parent object in the Person table
// 2. Locate a column with the columnName name in the Person table
// 3. Using the column definition, Backendless will identify the child table
// 4. Backendless will retrieve the child objects from the child table using
// the provided objectId values.
// 5. Backendless will disconnect the child objects from the relationship
// with the parent object.
unitOfWorkInstance.deleteRelation(parentObject: YourCustomClassForParent,
columnName: String,
childrenObjectIds: [String]) -> OpResult
// Same as the above with the only difference is the child objects are
// represented through a custom class. It is important that
// YourCustomClassForChild matches the child table name. For example,
// if the relationship is between tables Person and Address, then the
// YourCustomClassForChild class must be "Address".
unitOfWorkInstance.deleteRelation(parentObject: YourCustomClassForParent,
columnName: String,
customChildren: [YourCustomClassForChild]) -> OpResult
// Same as the first signature above with the only difference is the child
// objects are instances of the Map interface. It is important that each
// Map object has a key/value pair for the "objectId" property with a
// valid value.
deleteRelation(parentObject: YourCustomClassForParent,
columnName: String,
children: [[String : Any]]) -> OpResult
// Same as the first signature above with the only difference is the children
// argument is a result of a previous operation in the same transaction. It
// must represent either a collection of string values (objectIds) or a
// collection of objects. This is possible with the following previous
// operations:
// - Retrieving objects from the database
// - Saving multiple objects in the database
// It is important that all child objects referenced by the children argument
// exist in the child table that columnName points to.
unitOfWorkInstance.deleteRelation(parentObject: YourCustomClassForParent,
columnName: String,
childrenResult: OpResult) -> OpResult
// Disconnect the children identified with their objectId values in the
// childrenObjectId array from parentObject for the relationship identified
// by the column with the name of columnName. The parentObject value is a
// result of a previous operation in the same transaction. These
// operations can be:
// - Saving a single object in the database
// - Updating a single object in the database
// The relationship column must be declared in the same table where
// parentObject comes from. It is important that all child objects in the
// childrenObjectId array exists in the child table that columnName points to.
unitOfWorkInstance.deleteRelation(parentResult: OpResult,
columnName: String,
childrenObjectIds: [String]) -> OpResult
// Same as the above with the difference that the child objects are instances
// of the YourCustomClassForChildren class. The class used for child objects
// must match the name of the child table. Suppose the relationship is
// between tables Person and Address. In this case, the name of the class
// must be Address.
unitOfWorkInstance.deleteRelation(parentResult: OpResult,
columnName: String,
customChildren: [YourCustomClassForChildren]) -> OpResult
// Same as the first signature above with the only difference is the child
// objects are instances of the Map interface. It is important that each Map
// object has a key/value pair for the "objectId" property with a valid value.
unitOfWorkInstance.deleteRelation(parentResult: OpResult,
columnName: String,
children: [[String : Any]]) -> OpResult
// In this operation both the parent and the children objects are results of
// two separate previous operations in the same transaction. The parent
// object must be a result of any of the following operations:
// - Saving a single object in the database
// - Updating a single object in the database
// The relationship is identified through the column with the name in the
// columnName argument. The column must be declared in the same table where
// parentObject comes from. The children argument can be a result of the
// following operations:
// - Retrieving objects from the database
// - Saving multiple objects in the database
// It is important that all child objects referenced by the children argument
// exist in the child table that columnName points to.
unitOfWorkInstance.deleteRelation(parentResult: OpResult,
columnName: String,
childrenResult: OpResult) -> OpResult
// This method and the ones listed below identify the parent object the
// same way - using the OpResultValueReference class. This is a special
// class which references an object within a result of another operation
// within the same transaction. For example, a result of another operation
// can be a collection of objects. That collection can be returned from
// either the "Retrieving objects" or "Saving multiple objects" operations.
// All transaction operations return an OpResult object. Using the OpResult
// API you can obtain a single object which can be used as parent in the
// operations listed below. When a single object from a collection represented
// by OpResult is referenced, it is represented by the OpResultValueReference
// class.
unitOfWorkInstance.deleteRelation(parentValueReference: OpResultValueReference,
columnName: String,
childrenObjectIds: [String]) -> OpResult
unitOfWorkInstance.deleteRelation(parentValueReference: OpResultValueReference,
columnName: String,
customChildren: [YourCustomClassForChildren]) -> OpResult
unitOfWorkInstance.deleteRelation(parentValueReference: OpResultValueReference,
columnName: String,
children: [[String : Any]]) -> OpResult
unitOfWorkInstance.deleteRelation(parentValueReference: OpResultValueReference,
columnName: String,
childrenResult: OpResult) -> OpResult
Children with a Query¶
There are APIs where the child objects can be identified with a query using a where clause. These APIs run a query to get the child objects and then disconnect them from the parent in the relation. Again the APIs are grouped by how the parent object is identified:
// Disconnect the child objects identified by whereClauseForChildren from the parent object identified
// with parentObjectId. The parent object must be in the table with the parentTableName name.
// The relationship column between the parent and child objects is columnName. The whereClauseForChildren
// query is executed in the child table that columnName points to.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentTableName:(NSString * _Nonnull)
parentObjectId:(NSString * _Nonnull)
columnName:(NSString * _Nonnull)
whereClauseForChildren:(NSString * _Nonnull)];
// Disconnect/remove the objects identified by whereClauseForChildren from
// the parent object represented by the parentObject map for a relationship// identified by column columnName. The parent object must be in the table
// with the parentTableName name.
// The whereClauseForChildren query is executed in the child table that the columnName
// column points to. Objects which match the whereClauseForChildren query are then
// disconnected from the parent object.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentTableName:(NSString * _Nonnull)
parentObject:(NSDictionary<NSString *,id> * _Nonnull)
columnName:(NSString * _Nonnull)
whereClauseForChildren:(NSString * _Nonnull)];
// Disconnect the objects identified by whereClauseForChildren from
// the parent object represented as an instance of the YourCustomClassForParent
// class. The relationship column between the parent and child objects is columnName.
// Since the parent object is an instance of YourCustomClassForParent, it
// means the parent table where the parent object is stored must match the
// name of the class. For example, if YourCustomClassForParent
// is "Person", it means Backendless wiil:
// 1. Look for the parent object in the Person table.
// 2. Locate a column with the columnName name in the Person table.
// 3. Using the column definition, Backendless will identify the child table.
// 4. Backendless will run the whereClauseForChildren query in the child table
// to identify the child objects.
// 5. Backendless wiil disconnect the child objects from the parent object
// for the relationship.
// The YourCustomClassForParent class must declare public get/set methods for the
// objectId property or have a public objectId field.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentObject:(YourCustomClassForParent * _Nonnull)
columnName:(NSString * _Nonnull)
whereClauseForChildren:(NSString * _Nonnull)];
// Disconnect/remove the objects identified by the whereClauseForChildren
// query from the parent object. The parentObject value is a result of a previous
// operation in the same transaction. These operations can be:
// - Saving a single object in the database
// - Updating a single object in the database
// The relationship is identified through the column with the name in
// the columnName argument. The column must be declared in the same table
// where parentObject comes from.
// For example, if the parent object is stored in a table called "Person", Backendless wiil:
// 1. Look for the parent object in the Person table
// 2. Locate a column with the columnName name in the Person table
// 3. Using the column definition, Backendless will identify the child table
// 4. Backendless will run the whereClauseForChildren query in the child table to
// identify the child objects
// 5. Backendless will disconnect the child objects from the parent object for
// the relationship.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentResult:(OpResult * _Nonnull)
columnName:(NSString * _Nonnull)
whereClauseForChildren:(NSString * _Nonnull)];
// Same as the above except the parent object is a reference to an object
// within a result of another operation in the same transaction. For example,
// a result of another operation can be a collection of objects. That collection
// can be returning from either the "Retrieving objects" or "Saving multiple objects"
// operations. Using the OpResult API you can obtain a single object which can be
// used as parent in this operation. When a single object from a collection
// represented by OpResult is referenced, it is represented by the
// OpResultValueReference class.
- (OpResult *)[unitOfWorkInstance
deleteRelationWithParentValueReference:(OpResultValueReference * _Nonnull)
columnName:(NSString * _Nonnull)
whereClauseForChildren:(NSString * _Nonnull)];
// Disconnect the child objects identified by whereClauseForChildren from the parent object identified
// with parentObjectId. The parent object must be in the table with the parentTableName name.
// The relationship column between the parent and child objects is columnName. The whereClauseForChildren
// query is executed in the child table that columnName points to.
unitOfWorkInstance.deleteRelation(parentTableName: String,
parentObjectId: String,
columnName: String,
whereClauseForChildren: String) -> OpResult
// Disconnect/remove the objects identified by whereClauseForChildren from
// the parent object represented by the parentObject map for a relationship
// identified by column columnName. The parent object must be in the table
// with the parentTableName name.
// The whereClauseForChildren query is executed in the child table that the columnName
// column points to. Objects which match the whereClauseForChildren query are then
// disconnected from the parent object.
unitOfWorkInstance.deleteRelation(parentTableName: String,
parentObject: [String : Any],
columnName: String,
whereClauseForChildren: String) -> OpResult
// Disconnect the objects identified by whereClauseForChildren from
// the parent object represented as an instance of the YourCustomClassForParent
// class. The relationship column between the parent and child objects is columnName.
// Since the parent object is an instance of YourCustomClassForParent, it
// means the parent table where the parent object is stored must match the
// name of the class. For example, if YourCustomClassForParent
// is "Person", it means Backendless wiil:
// 1. Look for the parent object in the Person table.
// 2. Locate a column with the columnName name in the Person table.
// 3. Using the column definition, Backendless will identify the child table.
// 4. Backendless will run the whereClauseForChildren query in the child table
// to identify the child objects.
// 5. Backendless wiil disconnect the child objects from the parent object
// for the relationship.
// The YourCustomClassForParent class must declare public get/set methods for the
// objectId property or have a public objectId field.
unitOfWorkInstance.deleteRelation(parentObject: YourCustomClassForParent,
columnName: String,
whereClauseForChildren: String) -> OpResult
// Disconnect/remove the objects identified by the whereClauseForChildren
// query from the parent object. The parentObject value is a result of a previous
// operation in the same transaction. These operations can be:
// - Saving a single object in the database
// - Updating a single object in the database
// The relationship is identified through the column with the name in
// the columnName argument. The column must be declared in the same table
// where parentObject comes from.
// For example, if the parent object is stored in a table called "Person", Backendless wiil:
// 1. Look for the parent object in the Person table
// 2. Locate a column with the columnName name in the Person table
// 3. Using the column definition, Backendless will identify the child table
// 4. Backendless will run the whereClauseForChildren query in the child table to
// identify the child objects
// 5. Backendless will disconnect the child objects from the parent object for
// the relationship.
unitOfWorkInstance.deleteRelation(parentResult: OpResult,
columnName: String,
whereClauseForChildren: String) -> OpResult
// Same as the above except the parent object is a reference to an object
// within a result of another operation in the same transaction. For example,
// a result of another operation can be a collection of objects. That collection
// can be returning from either the "Retrieving objects" or "Saving multiple objects"
// operations. Using the OpResult API you can obtain a single object which can be
// used as parent in this operation. When a single object from a collection
// represented by OpResult is referenced, it is represented by the
// OpResultValueReference class.
unitOfWorkInstance.deleteRelation(parentValueReference: OpResultValueReference,
columnName: String,
whereClauseForChildren: String) -> OpResult
Return Value¶
The operation returns an OpResult
object which represents the result of this operation - number of child objects disconnected from the parent in  the relation.
Examples¶
The examples are organized by two levels: first is how the parent object is represented in the client program, then by the type of the child collection.
Parent object is represented as
** The child objects are represented as**
UnitOfWork *unitOfWork = [UnitOfWork new];
// This is an array for child objects.
// They are referenced using objectId values.
// The example hard-codes the array, but in
// your code you'd get the objectId values
// from your data model or using a query
NSArray *giftIds = @[@"EE3BF4B5-DB88-1425-FF89-CC11B7707500",
@"0CF23E36-FCC0-4E04-FF3E-8B67E6E27200",
@"DFFEDE1D-E423-2472-FF71-26EEC3F23700"];
// this is the objectId of the parent object.
NSString *personObjectId = @"E7AD83E0-1B4E-D250-FF46-61BFAB18D700";
// the name of the table where the parent object is stored
NSString *parentTableName = @"Person";
// the name of the relation column
NSString *relationColumnName = @"wishlist";
// add the deleteRelation call to the transaction
[unitOfWork
deleteRelationWithParentTableName:parentTableName
parentObjectId:personObjectId
columnName:relationColumnName
childrenObjectIds:giftIds];
// run the transaction
[unitOfWork executeWithResponseHandler:^(UnitOfWorkResult *result) {
NSLog(@"Transaction complete - %@", result);
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
UnitOfWork *unitOfWork = [UnitOfWork new];
// This is a list of gift objects. These objects
// will be children in the relationship. As you
// can see the objects are constructed manually
// and their objectId's are set, however, in your
// application they would be loaded from the
// server. This is done here to keep the example
// more succinct.
NSMutableArray *gifts = [NSMutableArray new];
NSDictionary *iPad = @{@"objectId": @"EE3BF4B5-DB88-1425-FF89-CC11B7707500"};
[gifts addObject:iPad];
NSDictionary *iPhone = @{@"objectId": @"0CF23E36-FCC0-4E04-FF3E-8B67E6E27200"};
[gifts addObject:iPhone];
// this is the objectId of the parent object.
NSString *personObjectId = @"E7AD83E0-1B4E-D250-FF46-61BFAB18D700";
// the name of the table where the parent object is stored
NSString *parentTableName = @"Person";
// the name of the relation column
NSString *relationColumnName = @"wishlist";
// add the deleteRelation call to the transaction
[unitOfWork
deleteRelationWithParentTableName:parentTableName
parentObjectId:personObjectId
columnName:relationColumnName
children:gifts];
// run the transaction
[unitOfWork executeWithResponseHandler:^(UnitOfWorkResult *result) {
NSLog(@"Transaction complete - %@", result);
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
UnitOfWork *unitOfWork = [UnitOfWork new];
// This is a list of gift objects. These objects
// will be children in the relationship. As you
// can see the objects are constructed manually
// and their objectId's are set, however, in your
// application they would be loaded from the
// server. This is done here to keep the example
// more succinct.
NSMutableArray *gifts = [NSMutableArray new];
Gift *iPad = [Gift new];
iPad.objectId = @"EE3BF4B5-DB88-1425-FF89-CC11B7707500";
[gifts addObject:iPad];
Gift *iPhone = [Gift new];
iPhone.objectId = @"0CF23E36-FCC0-4E04-FF3E-8B67E6E27200";
[gifts addObject:iPhone];
// this is the objectId of the parent object.
NSString *personObjectId = @"E7AD83E0-1B4E-D250-FF46-61BFAB18D700";
// the name of the table where the parent object is stored
NSString *parentTableName = @"Person";
// the name of the relation column
NSString *relationColumnName = @"wishlist";
// add the deleteRelation call to the transaction
[unitOfWork
deleteRelationWithParentTableName:parentTableName
parentObjectId:personObjectId
columnName:relationColumnName
customChildren:gifts];
// run the transaction
[unitOfWork executeWithResponseHandler:^(UnitOfWorkResult *result) {
NSLog(@"Transaction complete - %@", result);
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
@interface Gift : NSObject
@property (strong, nonatomic) NSString *objectId;
@property (strong, nonatomic) NSString *name;
@property double price;
@end
UnitOfWork *unitOfWork = [UnitOfWork new];
// compose a query to fetch the gift objects
DataQueryBuilder *queryBuilder = [DataQueryBuilder new];
queryBuilder.whereClause = @"name in ( 'Apple iPad', 'Apple iPhone', 'Selfie Stick')";
// add the find operation to the transaction
// notice the result of the operation is saved in a variable -
// it will be used further in the addToRelation operation
OpResult *gifts = [unitOfWork findWithTableName:@"Gift" queryBuilder:queryBuilder];
// this is the objectId of the parent object.
NSString *personObjectId = @"E7AD83E0-1B4E-D250-FF46-61BFAB18D700";
// the name of the table where the parent object is stored
NSString *parentTableName = @"Person";
// the name of the relation column
NSString *relationColumnName = @"wishlist";
// add the deleteRelation call to the transaction
[unitOfWork
deleteRelationWithParentTableName:parentTableName
parentObjectId:personObjectId
columnName:relationColumnName
childrenResult:gifts];
// run the transaction
[unitOfWork executeWithResponseHandler:^(UnitOfWorkResult *result) {
NSLog(@"Transaction complete - %@", result);
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
** The child objects are represented as**
UnitOfWork *unitOfWork = [UnitOfWork new];
// This is an array for child objects.
// They are referenced using objectId values.
// The example hard-codes the array, but in
// your code you'd get the objectId values
// from your data model or using a query
NSArray *giftIds = @[@"EE3BF4B5-DB88-1425-FF89-CC11B7707500",
@"0CF23E36-FCC0-4E04-FF3E-8B67E6E27200",
@"DFFEDE1D-E423-2472-FF71-26EEC3F23700"];
// this is the parent object. The only property that
// matters for the sake of establishing a relation
// is objectId. In your program you would be
// retrieving the object from the server. The
// technique shown here is for code brevity.
NSDictionary *personObject = @{@"objectId": @"E7AD83E0-1B4E-D250-FF46-61BFAB18D700"};
// the name of the table where the parent object is stored
NSString *parentTableName = @"Person";
// the name of the relation column
NSString *relationColumnName = @"wishlist";
// add the deleteRelation call to the transaction
[unitOfWork
deleteRelationWithParentTableName:parentTableName
parentObject:personObject
columnName:relationColumnName
childrenObjectIds:giftIds];
// run the transaction
[unitOfWork executeWithResponseHandler:^(UnitOfWorkResult *result) {
NSLog(@"Transaction complete - %@", result);
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
UnitOfWork *unitOfWork = [UnitOfWork new];
// This is a list of gift objects. These objects
// will be children in the relationship. As you
// can see the objects are constructed manually
// and their objectId's are set, however, in your
// application they would be loaded from the
// server. This is done here to keep the example
// more succinct.
NSMutableArray *gifts = [NSMutableArray new];
NSDictionary *iPad = @{@"objectId": @"EE3BF4B5-DB88-1425-FF89-CC11B7707500"};
[gifts addObject:iPad];
NSDictionary *iPhone = @{@"objectId": @"0CF23E36-FCC0-4E04-FF3E-8B67E6E27200"};
[gifts addObject:iPhone];
// this is the parent object. The only property that
// matters for the sake of establishing a relation
// is objectId. In your program you would be
// retrieving the object from the server. The
// technique shown here is for code brevity.
NSDictionary *personObject = @{@"objectId": @"E7AD83E0-1B4E-D250-FF46-61BFAB18D700"};
// the name of the table where the parent object is stored
NSString *parentTableName = @"Person";
// the name of the relation column
NSString *relationColumnName = @"wishlist";
// add the deleteRelation call to the transaction
[unitOfWork
deleteRelationWithParentTableName:parentTableName
parentObject:personObject
columnName:relationColumnName
children:gifts];
// run the transaction
[unitOfWork executeWithResponseHandler:^(UnitOfWorkResult *result) {
NSLog(@"Transaction complete - %@", result);
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
UnitOfWork *unitOfWork = [UnitOfWork new];
// This is a list of gift objects. These objects
// will be children in the relationship. As you
// can see the objects are constructed manually
// and their objectId's are set, however, in your
// application they would be loaded from the
// server. This is done here to keep the example
// more succinct.
NSMutableArray *gifts = [NSMutableArray new];
Gift *iPad = [Gift new];
iPad.objectId = @"EE3BF4B5-DB88-1425-FF89-CC11B7707500";
[gifts addObject:iPad];
Gift *iPhone = [Gift new];
iPhone.objectId = @"0CF23E36-FCC0-4E04-FF3E-8B67E6E27200";
[gifts addObject:iPhone];
// this is the parent object. The only property that
// matters for the sake of establishing a relation
// is objectId. In your program you would be
// retrieving the object from the server. The
// technique shown here is for code brevity.
NSDictionary *personObject = @{@"objectId": @"E7AD83E0-1B4E-D250-FF46-61BFAB18D700"};
// the name of the table where the parent object is stored
NSString *parentTableName = @"Person";
// the name of the relation column
NSString *relationColumnName = @"wishlist";
// add the deleteRelation call to the transaction
[unitOfWork
deleteRelationWithParentTableName:parentTableName
parentObject:personObject
columnName:relationColumnName
customChildren:gifts];
// run the transaction
[unitOfWork executeWithResponseHandler:^(UnitOfWorkResult *result) {
NSLog(@"Transaction complete - %@", result);
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
@interface Gift : NSObject
@property (strong, nonatomic) NSString *objectId;
@property (strong, nonatomic) NSString *name;
@property double price;
@end
UnitOfWork *unitOfWork = [UnitOfWork new];
// compose a query to fetch the gift objects
DataQueryBuilder *queryBuilder = [DataQueryBuilder new];
queryBuilder.whereClause = @"name in ( 'Apple iPad', 'Apple iPhone', 'Selfie Stick')";
// add the find operation to the transaction
// notice the result of the operation is saved in a variable -
// it will be used further in the addToRelation operation
OpResult *gifts = [unitOfWork findWithTableName:@"Gift" queryBuilder:queryBuilder];
// this is the parent object. The only property that
// matters for the sake of establishing a relation
// is objectId. In your program you would be
// retrieving the object from the server. The
// technique shown here is for code brevity.
NSDictionary *personObject = @{@"objectId": @"E7AD83E0-1B4E-D250-FF46-61BFAB18D700"};
// the name of the table where the parent object is stored
NSString *parentTableName = @"Person";
// the name of the relation column
NSString *relationColumnName = @"wishlist";
// add the deleteRelation call to the transaction
[unitOfWork
deleteRelationWithParentTableName:parentTableName
parentObject:personObject
columnName:relationColumnName
childrenResult:gifts];
// run the transaction
[unitOfWork executeWithResponseHandler:^(UnitOfWorkResult *result) {
NSLog(@"Transaction complete - %@", result);
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
** The child objects are represented as**
UnitOfWork *unitOfWork = [UnitOfWork new];
// This is an array for child objects.
// They are referenced using objectId values.
// The example hard-codes the array, but in
// your code you'd get the objectId values
// from your data model or using a query
NSArray *giftIds = @[@"EE3BF4B5-DB88-1425-FF89-CC11B7707500",
@"0CF23E36-FCC0-4E04-FF3E-8B67E6E27200",
@"DFFEDE1D-E423-2472-FF71-26EEC3F23700"];
// this is the parent object. The only property that
// matters for the sake of establishing a relation
// is objectId. In your program you would be
// retrieving the object from the server. The
// technique shown here is for code brevity.
Person *personObject = [Person new];
personObject.objectId = @"E7AD83E0-1B4E-D250-FF46-61BFAB18D700";
// the name of the relation column
NSString *relationColumnName = @"wishlist";
// add the deleteRelation call to the transaction
[unitOfWork
deleteRelationWithParentObject:personObject
columnName:relationColumnName
childrenObjectIds:giftIds];
// run the transaction
[unitOfWork executeWithResponseHandler:^(UnitOfWorkResult *result) {
NSLog(@"Transaction complete - %@", result);
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
UnitOfWork *unitOfWork = [UnitOfWork new];
// This is a list of gift objects. These objects
// will be children in the relationship. As you
// can see the objects are constructed manually
// and their objectId's are set, however, in your
// application they would be loaded from the
// server. This is done here to keep the example
// more succinct.
NSMutableArray *gifts = [NSMutableArray new];
NSDictionary *iPad = @{@"objectId": @"EE3BF4B5-DB88-1425-FF89-CC11B7707500"};
[gifts addObject:iPad];
NSDictionary *iPhone = @{@"objectId": @"0CF23E36-FCC0-4E04-FF3E-8B67E6E27200"};
[gifts addObject:iPhone];
// this is the parent object. The only property that
// matters for the sake of establishing a relation
// is objectId. In your program you would be
// retrieving the object from the server. The
// technique shown here is for code brevity.
Person *personObject = [Person new];
personObject.objectId = @"E7AD83E0-1B4E-D250-FF46-61BFAB18D700";
// the name of the relation column
NSString *relationColumnName = @"wishlist";
// add the deleteRelation call to the transaction
[unitOfWork
deleteRelationWithParentObject:personObject
columnName:relationColumnName
children:gifts];
// run the transaction
[unitOfWork executeWithResponseHandler:^(UnitOfWorkResult *result) {
NSLog(@"Transaction complete - %@", result);
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
UnitOfWork *unitOfWork = [UnitOfWork new];
// This is a list of gift objects. These objects
// will be children in the relationship. As you
// can see the objects are constructed manually
// and their objectId's are set, however, in your
// application they would be loaded from the
// server. This is done here to keep the example
// more succinct.
NSMutableArray *gifts = [NSMutableArray new];
Gift *iPad = [Gift new];
iPad.objectId = @"EE3BF4B5-DB88-1425-FF89-CC11B7707500";
[gifts addObject:iPad];
Gift *iPhone = [Gift new];
iPhone.objectId = @"0CF23E36-FCC0-4E04-FF3E-8B67E6E27200";
[gifts addObject:iPhone];
// this is the parent object. The only property that
// matters for the sake of establishing a relation
// is objectId. In your program you would be
// retrieving the object from the server. The
// technique shown here is for code brevity.
Person *personObject = [Person new];
personObject.objectId = @"E7AD83E0-1B4E-D250-FF46-61BFAB18D700";
// the name of the relation column
NSString *relationColumnName = @"wishlist";
// add the deleteRelation call to the transaction
[unitOfWork
deleteRelationWithParentObject:personObject
columnName:relationColumnName
customChildren:gifts];
// run the transaction
[unitOfWork executeWithResponseHandler:^(UnitOfWorkResult *result) {
NSLog(@"Transaction complete - %@", result);
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
@interface Gift : NSObject
@property (strong, nonatomic) NSString *objectId;
@property (strong, nonatomic) NSString *name;
@property double price;
@end
UnitOfWork *unitOfWork = [UnitOfWork new];
// compose a query to fetch the gift objects
DataQueryBuilder *queryBuilder = [DataQueryBuilder new];
queryBuilder.whereClause = @"name in ( 'Apple iPad', 'Apple iPhone', 'Selfie Stick')";
// add the find operation to the transaction
// notice the result of the operation is saved in a variable -
// it will be used further in the addToRelation operation
OpResult *gifts = [unitOfWork findWithTableName:@"Gift" queryBuilder:queryBuilder];
// this is the parent object. The only property that
// matters for the sake of establishing a relation
// is objectId. In your program you would be
// retrieving the object from the server. The
// technique shown here is for code brevity.
Person *personObject = [Person new];
personObject.objectId = @"E7AD83E0-1B4E-D250-FF46-61BFAB18D700";
// the name of the relation column
NSString *relationColumnName = @"wishlist";
// add the deleteRelation call to the transaction
[unitOfWork
deleteRelationWithParentObject:personObject
columnName:relationColumnName
childrenResult:gifts];
// run the transaction
[unitOfWork executeWithResponseHandler:^(UnitOfWorkResult *result) {
NSLog(@"Transaction complete - %@", result);
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
** The child objects are represented as**
UnitOfWork *unitOfWork = [UnitOfWork new];
// This is an array for child objects.
// They are referenced using objectId values.
// The example hard-codes the array, but in
// your code you'd get the objectId values
// from your data model or using a query
NSArray *giftIds = @[@"EE3BF4B5-DB88-1425-FF89-CC11B7707500",
@"0CF23E36-FCC0-4E04-FF3E-8B67E6E27200",
@"DFFEDE1D-E423-2472-FF71-26EEC3F23700"];
// compose a query to retrieve the person
// from the database
DataQueryBuilder *queryBuilder = [DataQueryBuilder new];
// this is the query which identifies the person of interest,
// this person object will be used as the parent in the relationship
queryBuilder.whereClause = @"name = 'John Doe' and age = 36";
// add the object retrieval operation to the transaction
OpResult *findResult = [unitOfWork findWithTableName:@"Person" queryBuilder:queryBuilder];
// since "findResult" references a collection of objects,
// get the first one from the collection. The reason we need to
// do this is because the deleteRelation operation below
// expects only one parent object. We know the first object
// will be the parent, that's why the "resolveTo" index is 0.
OpResultValueReference *parentObjectRef = [findResult resolveToResultIndex:@0];
// the name of the relation column
NSString *relationColumnName = @"wishlist";
// add the deleteRelation call to the transaction
[unitOfWork
deleteRelationWithParentValueReference:parentObjectRef
columnName:relationColumnName
childrenObjectIds:giftIds];
// run the transaction
[unitOfWork executeWithResponseHandler:^(UnitOfWorkResult *result) {
NSLog(@"Transaction complete - %@", result);
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
UnitOfWork *unitOfWork = [UnitOfWork new];
// This is a list of gift objects. These objects
// will be children in the relationship. As you
// can see the objects are constructed manually
// and their objectId's are set, however, in your
// application they would be loaded from the
// server. This is done here to keep the example
// more succinct.
NSMutableArray *gifts = [NSMutableArray new];
NSDictionary *iPad = @{@"objectId": @"EE3BF4B5-DB88-1425-FF89-CC11B7707500"};
[gifts addObject:iPad];
NSDictionary *iPhone = @{@"objectId": @"0CF23E36-FCC0-4E04-FF3E-8B67E6E27200"};
[gifts addObject:iPhone];
// compose a query to retrieve the person
// from the database
DataQueryBuilder *queryBuilder = [DataQueryBuilder new];
// this is the query which identifies the person of interest,
// this person object will be used as the parent in the relationship
queryBuilder.whereClause = @"name = 'John Doe' and age = 36";
// add the object retrieval operation to the transaction
OpResult *findResult = [unitOfWork findWithTableName:@"Person" queryBuilder:queryBuilder];
// since "findResult" references a collection of objects,
// get the first one from the collection. The reason we need to
// do this is because the deleteRelation operation below
// expects only one parent object. We know the first object
// will be the parent, that's why the "resolveTo" index is 0.
OpResultValueReference *parentObjectRef = [findResult resolveToResultIndex:@0];
// the name of the relation column
NSString *relationColumnName = @"wishlist";
// add the deleteRelation call to the transaction
[unitOfWork
deleteRelationWithParentValueReference:parentObjectRef
columnName:relationColumnName
children: gifts];
// run the transaction
[unitOfWork executeWithResponseHandler:^(UnitOfWorkResult *result) {
NSLog(@"Transaction complete - %@", result);
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
UnitOfWork *unitOfWork = [UnitOfWork new];
// This is a list of gift objects. These objects
// will be children in the relationship. As you
// can see the objects are constructed manually
// and their objectId's are set, however, in your
// application they would be loaded from the
// server. This is done here to keep the example
// more succinct.
NSMutableArray *gifts = [NSMutableArray new];
Gift *iPad = [Gift new];
iPad.objectId = @"EE3BF4B5-DB88-1425-FF89-CC11B7707500";
[gifts addObject:iPad];
Gift *iPhone = [Gift new];
iPhone.objectId = @"0CF23E36-FCC0-4E04-FF3E-8B67E6E27200";
[gifts addObject:iPhone];
// compose a query to retrieve the person
// from the database
DataQueryBuilder *queryBuilder = [DataQueryBuilder new];
// this is the query which identifies the person of interest,
// this person object will be used as the parent in the relationship
queryBuilder.whereClause = @"name = 'John Doe' and age = 36";
// add the object retrieval operation to the transaction
OpResult *findResult = [unitOfWork findWithTableName:@"Person" queryBuilder:queryBuilder];
// since "findResult" references a collection of objects,
// get the first one from the collection. The reason we need to
// do this is because the deleteRelation operation below
// expects only one parent object. We know the first object
// will be the parent, that's why the "resolveTo" index is 0.
OpResultValueReference *parentObjectRef = [findResult resolveToResultIndex:@0];
// the name of the relation column
NSString *relationColumnName = @"wishlist";
// add the deleteRelation call to the transaction
[unitOfWork
deleteRelationWithParentValueReference:parentObjectRef
columnName:relationColumnName
customChildren: gifts];
// run the transaction
[unitOfWork executeWithResponseHandler:^(UnitOfWorkResult *result) {
NSLog(@"Transaction complete - %@", result);
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
@interface Gift : NSObject
@property (strong, nonatomic) NSString *objectId;
@property (strong, nonatomic) NSString *name;
@property double price;
@end
UnitOfWork *unitOfWork = [UnitOfWork new];
// compose a query to fetch the gift objects
DataQueryBuilder *queryBuilder = [DataQueryBuilder new];
queryBuilder.whereClause = @"name in ( 'Apple iPad', 'Apple iPhone', 'Selfie Stick')";
// add the find operation to the transaction
// notice the result of the operation is saved in a variable -
// it will be used further in the addToRelation operation
OpResult *gifts = [unitOfWork findWithTableName:@"Gift" queryBuilder:queryBuilder];
// compose a query to retrieve the person
// from the database
DataQueryBuilder *parentQueryBuilder = [DataQueryBuilder new];
// this is the query which identifies the person of interest,
// this person object will be used as the parent in the relationship
parentQueryBuilder.whereClause = @"name = 'John Doe' and age = 36";
// add the object retrieval operation to the transaction
OpResult *findResult = [unitOfWork findWithTableName:@"Person" queryBuilder:queryBuilder];
// since "findResult" references a collection of objects,
// get the first one from the collection. The reason we need to
// do this is because the deleteRelation operation below
// expects only one parent object. We know the first object
// will be the parent, that's why the "resolveTo" index is 0.
OpResultValueReference *parentObjectRef = [findResult resolveToResultIndex:@0];
// the name of the relation column
NSString *relationColumnName = @"wishlist";
// add the deleteRelation call to the transaction
[unitOfWork
deleteRelationWithParentValueReference:parentObjectRef
columnName:relationColumnName
childrenResult: gifts];
// run the transaction
[unitOfWork executeWithResponseHandler:^(UnitOfWorkResult *result) {
NSLog(@"Transaction complete - %@", result);
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
** The child objects are represented as**
let unitOfWork = UnitOfWork()
// This is an array for child objects.
// They are referenced using objectId values.
// The example hard-codes the array, but in
// your code you'd get the objectId values
// from your data model or using a query
let giftIds = ["EE3BF4B5-DB88-1425-FF89-CC11B7707500",
"0CF23E36-FCC0-4E04-FF3E-8B67E6E27200",
"DFFEDE1D-E423-2472-FF71-26EEC3F23700"]
// this is the objectId of the parent object.
let personObjectId = "E7AD83E0-1B4E-D250-FF46-61BFAB18D700"
// the name of the table where the parent object is stored
let parentTableName = "Person"
// the name of the relation column
let relationColumnName = "wishlist"
// add the deleteRelation call to the transaction
let _ = unitOfWork.deleteRelation(parentTableName: parentTableName,
parentObjectId: personObjectId,
columnName: relationColumnName,
childrenObjectIds: giftIds)
// run the transaction
unitOfWork.execute(responseHandler: { result in
print("Transaction complete - \(result)")
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
let unitOfWork = UnitOfWork()
// This is a list of gift objects. These objects
// will be children in the relationship. As you
// can see the objects are constructed manually
// and their objectId's are set, however, in your
// application they would be loaded from the
// server. This is done here to keep the example
// more succinct.
var gifts = [[String : Any]]()
let iPad = ["objectId": "EE3BF4B5-DB88-1425-FF89-CC11B7707500"]
gifts.append(iPad)
let iPhone = ["objectId": "0CF23E36-FCC0-4E04-FF3E-8B67E6E27200"]
gifts.append(iPhone)
// this is the objectId of the parent object.
let personObjectId = "E7AD83E0-1B4E-D250-FF46-61BFAB18D700"
// the name of the table where the parent object is stored
let parentTableName = "Person"
// the name of the relation column
let relationColumnName = "wishlist"
// add the deleteRelation call to the transaction
let _ = unitOfWork.deleteRelation(parentTableName: parentTableName,
parentObjectId: personObjectId,
columnName: relationColumnName,
children: gifts)
// run the transaction
unitOfWork.execute(responseHandler: { result in
print("Transaction complete - \(result)")
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
let unitOfWork = UnitOfWork()
// This is a list of gift objects. These objects
// will be children in the relationship. As you
// can see the objects are constructed manually
// and their objectId's are set, however, in your
// application they would be loaded from the
// server. This is done here to keep the example
// more succinct.
var gifts = [Gift]()
let iPad = Gift()
iPad.objectId = "EE3BF4B5-DB88-1425-FF89-CC11B7707500"
gifts.append(iPad)
let iPhone = Gift()
iPhone.objectId = "0CF23E36-FCC0-4E04-FF3E-8B67E6E27200"
gifts.append(iPhone)
// this is the objectId of the parent object.
let personObjectId = "E7AD83E0-1B4E-D250-FF46-61BFAB18D700"
// the name of the table where the parent object is stored
let parentTableName = "Person"
// the name of the relation column
let relationColumnName = "wishlist"
// add the deleteRelation call to the transaction
let _ = unitOfWork.deleteRelation(parentTableName: parentTableName,
parentObjectId: personObjectId,
columnName: relationColumnName,
customChildren: gifts)
// run the transaction
unitOfWork.execute(responseHandler: { result in
print("Transaction complete - \(result)")
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
@objcMembers class Gift: NSObject {
var objectId: String?
var name: String?
var price: Double = 0.0
}
let unitOfWork = UnitOfWork()
// compose a query to fetch the gift objects
let queryBuilder = DataQueryBuilder()
queryBuilder.whereClause = "name in ( 'Apple iPad', 'Apple iPhone', 'Selfie Stick')"
// add the find operation to the transaction
// notice the result of the operation is saved in a variable -
// it will be used further in the deleteRelation operation
let gifts = unitOfWork.find(tableName: "Gift", queryBuilder: queryBuilder)
// this is the objectId of the parent object.
let personObjectId = "E7AD83E0-1B4E-D250-FF46-61BFAB18D700"
// the name of the table where the parent object is stored
let parentTableName = "Person"
// the name of the relation column
let relationColumnName = "wishlist"
// add the deleteRelation call to the transaction
let _ = unitOfWork.deleteRelation(parentTableName: parentTableName,
parentObjectId: personObjectId,
columnName: relationColumnName,
childrenResult: gifts)
// run the transaction
unitOfWork.execute(responseHandler: { result in
print("Transaction complete - \(result)")
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
** The child objects are represented as**
let unitOfWork = UnitOfWork()
// This is an array for child objects.
// They are referenced using objectId values.
// The example hard-codes the array, but in
// your code you'd get the objectId values
// from your data model or using a query
let giftIds = ["EE3BF4B5-DB88-1425-FF89-CC11B7707500",
"0CF23E36-FCC0-4E04-FF3E-8B67E6E27200",
"DFFEDE1D-E423-2472-FF71-26EEC3F23700"]
// this is the parent object. The only property that
// matters for the sake of establishing a relation
// is objectId. In your program you would be
// retrieving the object from the server. The
// technique shown here is for code brevity.
let personObject = ["objectId": "E7AD83E0-1B4E-D250-FF46-61BFAB18D700"]
// the name of the table where the parent object is stored
let parentTableName = "Person"
// the name of the relation column
let relationColumnName = "wishlist";
// add the deleteRelation call to the transaction
let _ = unitOfWork.deleteRelation(parentTableName: parentTableName,
parentObject: personObject,
columnName: relationColumnName,
childrenObjectIds: giftIds)
// run the transaction
unitOfWork.execute(responseHandler: { result in
print("Transaction complete - \(result)")
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
let unitOfWork = UnitOfWork()
// This is a list of gift objects. These objects
// will be children in the relationship. As you
// can see the objects are constructed manually
// and their objectId's are set, however, in your
// application they would be loaded from the
// server. This is done here to keep the example
// more succinct.
var gifts = [[String : Any]]()
let iPad = ["objectId": "EE3BF4B5-DB88-1425-FF89-CC11B7707500"]
gifts.append(iPad)
let iPhone = ["objectId": "0CF23E36-FCC0-4E04-FF3E-8B67E6E27200"]
gifts.append(iPhone)
// this is the parent object. The only property that
// matters for the sake of establishing a relation
// is objectId. In your program you would be
// retrieving the object from the server. The
// technique shown here is for code brevity.
let personObject = ["objectId": "E7AD83E0-1B4E-D250-FF46-61BFAB18D700"]
// the name of the table where the parent object is stored
let parentTableName = "Person"
// the name of the relation column
let relationColumnName = "wishlist"
// add the deleteRelation call to the transaction
let _ = unitOfWork.deleteRelation(parentTableName: parentTableName,
parentObject: personObject,
columnName: relationColumnName,
children: gifts)
// run the transaction
unitOfWork.execute(responseHandler: { result in
print("Transaction complete - \(result)")
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
let unitOfWork = UnitOfWork()
// This is a list of gift objects. These objects
// will be children in the relationship. As you
// can see the objects are constructed manually
// and their objectId's are set, however, in your
// application they would be loaded from the
// server. This is done here to keep the example
// more succinct.
var gifts = [Gift]()
let iPad = Gift()
iPad.objectId = "EE3BF4B5-DB88-1425-FF89-CC11B7707500"
gifts.append(iPad)
let iPhone = Gift()
iPhone.objectId = "0CF23E36-FCC0-4E04-FF3E-8B67E6E27200"
gifts.append(iPhone)
// this is the parent object. The only property that
// matters for the sake of establishing a relation
// is objectId. In your program you would be
// retrieving the object from the server. The
// technique shown here is for code brevity.
let personObject = ["objectId": "E7AD83E0-1B4E-D250-FF46-61BFAB18D700"]
// the name of the table where the parent object is stored
let parentTableName = "Person"
// the name of the relation column
let relationColumnName = "wishlist"
// add the deleteRelation call to the transaction
let _ = unitOfWork.deleteRelation(parentTableName: parentTableName,
parentObject: personObject,
columnName: relationColumnName,
customChildren: gifts)
// run the transaction
unitOfWork.execute(responseHandler: { result in
print("Transaction complete - \(result)")
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
@objcMembers class Gift: NSObject {
var objectId: String?
var name: String?
var price: Double = 0.0
}
let unitOfWork = UnitOfWork()
// compose a query to fetch the gift objects
let queryBuilder = DataQueryBuilder()
queryBuilder.whereClause = "name in ( 'Apple iPad', 'Apple iPhone', 'Selfie Stick')"
// add the find operation to the transaction
// notice the result of the operation is saved in a variable -
// it will be used further in the deleteRelation operation
let gifts = unitOfWork.find(tableName: "Gift", queryBuilder: queryBuilder)
// this is the parent object. The only property that
// matters for the sake of establishing a relation
// is objectId. In your program you would be
// retrieving the object from the server. The
// technique shown here is for code brevity.
let personObject = ["objectId": "E7AD83E0-1B4E-D250-FF46-61BFAB18D700"]
// the name of the table where the parent object is stored
let parentTableName = "Person"
// the name of the relation column
let relationColumnName = "wishlist"
// add the deleteRelation call to the transaction
let _ = unitOfWork.deleteRelation(parentTableName: parentTableName,
parentObject: personObject,
columnName: relationColumnName,
childrenResult: gifts)
// run the transaction
unitOfWork.execute(responseHandler: { result in
print("Transaction complete - \(result)")
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
** The child objects are represented as**
let unitOfWork = UnitOfWork()
// This is an array for child objects.
// They are referenced using objectId values.
// The example hard-codes the array, but in
// your code you'd get the objectId values
// from your data model or using a query
let giftIds = ["EE3BF4B5-DB88-1425-FF89-CC11B7707500",
"0CF23E36-FCC0-4E04-FF3E-8B67E6E27200",
"DFFEDE1D-E423-2472-FF71-26EEC3F23700"]
// this is the parent object. The only property that
// matters for the sake of establishing a relation
// is objectId. In your program you would be
// retrieving the object from the server. The
// technique shown here is for code brevity.
let personObject = Person()
personObject.objectId = "E7AD83E0-1B4E-D250-FF46-61BFAB18D700"
// the name of the relation column
let relationColumnName = "wishlist"
// add the deleteRelation call to the transaction
let _ = unitOfWork.deleteRelation(parentObject: personObject,
columnName: relationColumnName,
childrenObjectIds: giftIds)
// run the transaction
unitOfWork.execute(responseHandler: { result in
print("Transaction complete - \(result)")
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
let unitOfWork = UnitOfWork()
// This is a list of gift objects. These objects
// will be children in the relationship. As you
// can see the objects are constructed manually
// and their objectId's are set, however, in your
// application they would be loaded from the
// server. This is done here to keep the example
// more succinct.
var gifts = [[String : Any]]()
let iPad = ["objectId": "EE3BF4B5-DB88-1425-FF89-CC11B7707500"]
gifts.append(iPad)
let iPhone = ["objectId": "0CF23E36-FCC0-4E04-FF3E-8B67E6E27200"]
gifts.append(iPhone)
// this is the parent object. The only property that
// matters for the sake of establishing a relation
// is objectId. In your program you would be
// retrieving the object from the server. The
// technique shown here is for code brevity.
let personObject = Person()
personObject.objectId = "E7AD83E0-1B4E-D250-FF46-61BFAB18D700"
// the name of the relation column
let relationColumnName = "wishlist"
// add the deleteRelation call to the transaction
let _ = unitOfWork.deleteRelation(parentObject: personObject,
columnName: relationColumnName,
children: gifts)
// run the transaction
unitOfWork.execute(responseHandler: { result in
print("Transaction complete - \(result)")
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
let unitOfWork = UnitOfWork()
// This is a list of gift objects. These objects
// will be children in the relationship. As you
// can see the objects are constructed manually
// and their objectId's are set, however, in your
// application they would be loaded from the
// server. This is done here to keep the example
// more succinct.
var gifts = [Gift]()
let iPad = Gift()
iPad.objectId = "EE3BF4B5-DB88-1425-FF89-CC11B7707500"
gifts.append(iPad)
let iPhone = Gift()
iPhone.objectId = "0CF23E36-FCC0-4E04-FF3E-8B67E6E27200"
gifts.append(iPhone)
// this is the parent object. The only property that
// matters for the sake of establishing a relation
// is objectId. In your program you would be
// retrieving the object from the server. The
// technique shown here is for code brevity.
let personObject = Person()
personObject.objectId = "E7AD83E0-1B4E-D250-FF46-61BFAB18D700"
// the name of the relation column
let relationColumnName = "wishlist"
// add the deleteRelation call to the transaction
let _ = unitOfWork.deleteRelation(parentObject: personObject,
columnName: relationColumnName,
customChildren: gifts)
// run the transaction
unitOfWork.execute(responseHandler: { result in
print("Transaction complete - \(result)")
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
@objcMembers class Gift: NSObject {
var objectId: String?
var name: String?
var price: Double = 0.0
}
let unitOfWork = UnitOfWork()
// compose a query to fetch the gift objects
let queryBuilder = DataQueryBuilder()
queryBuilder.whereClause = "name in ( 'Apple iPad', 'Apple iPhone', 'Selfie Stick')"
// add the find operation to the transaction
// notice the result of the operation is saved in a variable -
// it will be used further in the deleteRelation operation
let gifts = unitOfWork.find(tableName: "Gift", queryBuilder: queryBuilder)
// this is the parent object. The only property that
// matters for the sake of establishing a relation
// is objectId. In your program you would be
// retrieving the object from the server. The
// technique shown here is for code brevity.
let personObject = Person()
personObject.objectId = "E7AD83E0-1B4E-D250-FF46-61BFAB18D700"
// the name of the relation column
let relationColumnName = "wishlist"
// add the deleteRelation call to the transaction
let _ = unitOfWork.deleteRelation(parentObject: personObject,
columnName: relationColumnName,
childrenResult: gifts)
// run the transaction
unitOfWork.execute(responseHandler: { result in
print("Transaction complete - \(result)")
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
** The child objects are represented as**
let unitOfWork = UnitOfWork()
// This is an array for child objects.
// They are referenced using objectId values.
// The example hard-codes the array, but in
// your code you'd get the objectId values
// from your data model or using a query
let giftIds = ["EE3BF4B5-DB88-1425-FF89-CC11B7707500",
"0CF23E36-FCC0-4E04-FF3E-8B67E6E27200",
"DFFEDE1D-E423-2472-FF71-26EEC3F23700"]
// compose a query to retrieve the person
// from the database
let queryBuilder = DataQueryBuilder()
// this is the query which identifies the person of interest,
// this person object will be used as the parent in the relationship
queryBuilder.whereClause = "name = 'John Doe' and age = 36"
// add the object retrieval operation to the transaction
let findResult = unitOfWork.find(tableName: "Person", queryBuilder: queryBuilder)
// since "findResult" references a collection of objects,
// get the first one from the collection. The reason we need to
// do this is because the deleteRelation operation below
// expects only one parent object. We know the first object
// will be the parent, that's why the "resolveTo" index is 0.
let parentObjectRef = findResult.resolveTo(resultIndex: 0)
// the name of the relation column
let relationColumnName = "wishlist"
// add the deleteRelation call to the transaction
let _ = unitOfWork.deleteRelation(parentValueReference: parentObjectRef,
columnName: relationColumnName,
childrenObjectIds: giftIds)
// run the transaction
unitOfWork.execute(responseHandler: { result in
print("Transaction complete - \(result)")
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
let unitOfWork = UnitOfWork()
// This is a list of gift objects. These objects
// will be children in the relationship. As you
// can see the objects are constructed manually
// and their objectId's are set, however, in your
// application they would be loaded from the
// server. This is done here to keep the example
// more succinct.
var gifts = [[String : Any]]()
let iPad = ["objectId": "EE3BF4B5-DB88-1425-FF89-CC11B7707500"]
gifts.append(iPad)
let iPhone = ["objectId": "0CF23E36-FCC0-4E04-FF3E-8B67E6E27200"]
gifts.append(iPhone)
// compose a query to retrieve the person
// from the database
let queryBuilder = DataQueryBuilder()
// this is the query which identifies the person of interest,
// this person object will be used as the parent in the relationship
queryBuilder.whereClause = "name = 'John Doe' and age = 36"
// add the object retrieval operation to the transaction
let findResult = unitOfWork.find(tableName: "Person", queryBuilder: queryBuilder)
// since "findResult" references a collection of objects,
// get the first one from the collection. The reason we need to
// do this is because the deleteRelation operation below
// expects only one parent object. We know the first object
// will be the parent, that's why the "resolveTo" index is 0.
let parentObjectRef = findResult.resolveTo(resultIndex: 0)
// the name of the relation column
let relationColumnName = "wishlist"
// add the deleteRelation call to the transaction
let _ = unitOfWork.deleteRelation(parentValueReference: parentObjectRef,
columnName: relationColumnName,
children: gifts)
// run the transaction
unitOfWork.execute(responseHandler: { result in
print("Transaction complete - \(result)")
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
let unitOfWork = UnitOfWork()
// This is a list of gift objects. These objects
// will be children in the relationship. As you
// can see the objects are constructed manually
// and their objectId's are set, however, in your
// application they would be loaded from the
// server. This is done here to keep the example
// more succinct.
var gifts = [Gift]()
let iPad = Gift()
iPad.objectId = "EE3BF4B5-DB88-1425-FF89-CC11B7707500"
gifts.append(iPad)
let iPhone = Gift()
iPhone.objectId = "0CF23E36-FCC0-4E04-FF3E-8B67E6E27200"
gifts.append(iPhone)
// compose a query to retrieve the person
// from the database
let queryBuilder = DataQueryBuilder()
// this is the query which identifies the person of interest,
// this person object will be used as the parent in the relationship
queryBuilder.whereClause = "name = 'John Doe' and age = 36"
// add the object retrieval operation to the transaction
let findResult = unitOfWork.find(tableName: "Person", queryBuilder: queryBuilder)
// since "findResult" references a collection of objects,
// get the first one from the collection. The reason we need to
// do this is because the deleteRelation operation below
// expects only one parent object. We know the first object
// will be the parent, that's why the "resolveTo" index is 0.
let parentObjectRef = findResult.resolveTo(resultIndex: 0)
// the name of the relation column
let relationColumnName = "wishlist"
// add the deleteRelation call to the transaction
let _ = unitOfWork.deleteRelation(parentValueReference: parentObjectRef,
columnName: relationColumnName,
customChildren: gifts)
// run the transaction
unitOfWork.execute(responseHandler: { result in
print("Transaction complete - \(result)")
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
@objcMembers class Gift: NSObject {
var objectId: String?
var name: String?
var price: Double = 0.0
}
let unitOfWork = UnitOfWork()
// compose a query to fetch the gift objects
let queryBuilder = DataQueryBuilder()
queryBuilder.whereClause = "name in ( 'Apple iPad', 'Apple iPhone', 'Selfie Stick')"
// add the find operation to the transaction
// notice the result of the operation is saved in a variable -
// it will be used further in the deleteRelation operation
let gifts = unitOfWork.find(tableName: "Gift", queryBuilder: queryBuilder)
// compose a query to retrieve the person
// from the database
let parentQueryBuilder = DataQueryBuilder()
// this is the query which identifies the person of interest,
// this person object will be used as the parent in the relationship
parentQueryBuilder.whereClause = "name = 'John Doe' and age = 36"
// add the object retrieval operation to the transaction
let findResult = unitOfWork.find(tableName: "Person", queryBuilder: parentQueryBuilder)
// since "findResult" references a collection of objects,
// get the first one from the collection. The reason we need to
// do this is because the deleteRelation operation below
// expects only one parent object. We know the first object
// will be the parent, that's why the "resolveTo" index is 0.
let parentObjectRef = findResult.resolveTo(resultIndex: 0)
// the name of the relation column
let relationColumnName = "wishlist"
// add the deleteRelation call to the transaction
let _ = unitOfWork.deleteRelation(parentValueReference: parentObjectRef,
columnName: relationColumnName,
childrenResult: gifts)
// run the transaction
unitOfWork.execute(responseHandler: { result in
print("Transaction complete - \(result)")
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})