Method DeleteAsync
DeleteAsync(String, MapValue, DeleteOptions, CancellationToken)
Declaration
public Task<DeleteResult<RecordValue>> DeleteAsync(string tableName, MapValue primaryKey, DeleteOptions options = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
String | tableName | Name of the table. |
MapValue | primaryKey | Primary key of the row as MapValue representing names and values of the primary key fields. |
DeleteOptions | options | (Optional) Options for the Delete operation.
If not specified or null , appropriate defaults will be
used. See DeleteOptions. |
CancellationToken | cancellationToken | (Optional) Cancellation token. |
Returns
Type | Description |
---|---|
Task<DeleteResult<RecordValue>> | Task returning DeleteResult<TRow>. |
Remarks
The row is identified using a primary key value.
By default a delete operation is unconditional and will succeed if the specified row exists. Delete operations can be made conditional based on whether the RowVersion of an existing row matches that supplied by MatchVersion. Instead of using MatchVersion you may also use DeleteIfVersionAsync(String, MapValue, RowVersion, DeleteOptions, CancellationToken) API to perform the same conditional operation.
It is also possible, on failure, to return information about the
existing row. The row and its version can be optionally returned
as part of DeleteResult<TRow> if a delete operation
fails because of a version mismatch.The existing row information
will only be returned if
ReturnExisting is true
and
MatchVersion is set and the operation
fails because the row exists and its RowVersion does
not match the one provided.
Use of ReturnExisting may result in additional consumed read capacity and may affect the operation's latency. If the operation is successful there will be no information returned about the deleted row.
Note that the failures of conditional Delete operation as discussed above will not result in an exception and the DeleteResult<TRow> will still be returned.
Examples
Executing Delete operation on table with schema MyTable(id LONG, name STRING, PRIMARY KEY(id)).var result = await client.DeleteAsync(
"MyTable",
new MapValue
{
["id"] = 1000
});
// true if the delete succeeded, false if the row was not found
Console.WriteLine(result.Success);
Exceptions
Type | Condition |
---|---|
ArgumentException | If
tableName is null or invalid or
primaryKey is null or invalid or
options contains invalid values. |
TimeoutException | Operation has timed out. |
InvalidOperationException | The table or the service is not in a valid state to perform this operation. |
NoSQLException | NoSQLException or one of its subclasses is thrown if operation cannot be performed for any other reason. See documentation for corresponding subclass of NoSQLException. |