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

Count

The Count() 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 the number of found records. Since this operation requires to identify records inside a table you must provide the necessary Keys and values.

This method is a practical way to know how many table’s records have specific values.

_ = #UniRESTClient.Async#.$Count$(%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<int>
The function to call on operation completed.

int
the number of found records.

Example

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

Count() example
The following C# example shows the use of this method with this table. In this case, we are going to count how many records, with the health value equal to 1000, there are in the Players table.

_ = UniRESTClient.Async.Count(
        API.player_data,
        new DB.Players
        {
            health = 1000
        },
        "health",
        (int count) =>
        {
            Debug.Log("The are " + count + " records with health = 1000!");
        } 
);