1. Home
  2. Docs
  3. UniREST Solution 3.5
  4. UniREST Client
  5. Special Operations
  6. Exists

Exists

The Exists() method calls an API and performs records search into the Database table linked to the called API.
Result
The UniREST Server application will search for the records that respect the given search criteria (Keys and relative values). Then, it will reply with a simple confirmation if something has been found. Since this operation requires identifying records inside a table you must provide the necessary Keys and values.

This method is a practical way to know if a table contains records with specific values.

_ = #UniRESTClient.Async#.$Exists$(%api, tableData, fieldsToCheck, 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.
__
fieldsToCheck|string
The list of the columns name, separated by a space.
__
callBack|Action<bool>
The function to call on operation completed.

bool
true if the record exists, false if the record doesn’t exist or an error occurred.

Example

“Players” Database table
In this table, each record is a single player with its characteristics.

Exists() example
The following C# example shows the use of this method with this table. In this case, we are going to check if the Players table contains at least one record with the health value equal to 1000.

_ = UniRESTClient.Async.Exists(
        API.player_data,
        new DB.Players
        {
            health = 1000
        },
        "health",
        (bool exists) =>
        {
            if (exists)
            {
                  Debug.Log("The table contains records with health = 1000!");
            }
            else
            {
                  Debug.LogWarning("Record not found!");
            }
        } 
);