getRandom method

Future<APIResponse<List<Map<String, dynamic>>>> getRandom(
  1. int count
)

Retrieves the specified number of objects from the database randomly. See table below for applicable modifiers that can be used with this method.

Modifier Chained with getRandom?
filter
group
limit
lookup
omit
page
sort

If filter modifier is used with this method, Altogic first narrows down the set of objects that can be selected using the filter query and among these filtered objects performs random selection.

If the client library key is set to enforce session, an active user session is required (e.g., user needs to be logged in) to call this method.

count An integer that specifies the number of items to randomly select.

Returns the array of objects selected randomly.

Implementation

Future<APIResponse<List<Map<String, dynamic>>>> getRandom(int count) async {
  var res = await _call<List<dynamic>>(
      '/_api/rest/v1/db/get-random', {'count': count});
  return APIResponse(
      errors: res.errors, data: res.data?.cast<Map<String, dynamic>>());
}