1. Home
  2. Docs
  3. UniREST Solution 3.5
  4. UniREST Client
  5. Database Operations
  6. Delete

Delete

The Delete() method calls an API asking to delete one or more records from the Database table the API works with.
Result
The UniREST Server application will delete the found records and reply with a confirmation. Since this operation requires to identify the involved records, you must provide the necessary Keys.

_ = #UniRESTClient.Async#.$Delete$(%api, tableData, callBack%);

api|string
The API address, under the API class.
__
tableData|object
Optional values to send to the server. It must be an instance of the table class in use.
__
callBack|Action<bool>
The function to call on operation completed.

bool
true if the operation is completed, false if a system error occurred.

Since deleted records may not be recoverable, be very careful when configuring and using the Delete () method.

Example

“weapons/delete” API
This API deletes all the records of the “weapon” Database table that have the given player_id.

Delete() method
In this example, the Delete() method call the API.weapons_delete sending the player_id.

_ = UniRESTClient.Async.Delete(
     API.weapons_delete, 
     new DB.Weapon
     {
         player_id = UniRESTClient.UserID
     },
     (bool ok) =>
     {
          if (ok)
          {
               Debug.Log("Deleted!");
          }
          else
          {
               Debug.Log("Deleting failed");
          }
     }
);

If the debugMode is active (see the Debug Mode chapter for info), this method will show useful log messages if something goes wrong.