searchUsers method
- UserNum? num,
- UserLogin? login,
- ChatDirectLinkSlug? link,
- UserName? name,
- int? first,
- UsersCursor? after,
- int? last,
- UsersCursor? before,
Searches Users by the given criteria.
Exactly one of num/login/link/name arguments must be specified
(be non-null).
Searching by num/login/link is exact.
Searching by name is fuzzy.
Authentication
Optional.
Sorting
Returned Users are sorted depending on the provided arguments:
-
If one of the
num/login/linkarguments is specified, then an exact User is returned. -
If the
nameargument is specified, then returned Users are sorted primarily by theLevenshtein distanceof theirnames, and secondary by their IDs (if theLevenshtein distanceis the same), in descending order.
Pagination
It's allowed to specify both first and last counts at the same time,
provided that after and before cursors are equal. In such case the
returned page will include the User pointed by the cursor and the
requested count of Users preceding and following it.
If it's desired to receive the User, pointed by the cursor, without
querying in both directions, one can specify first or last count as 0.
Implementation
Future<SearchUsers$Query> searchUsers({
UserNum? num,
UserLogin? login,
ChatDirectLinkSlug? link,
UserName? name,
int? first,
UsersCursor? after,
int? last,
UsersCursor? before,
}) async {
Log.debug(
'searchUsers($num, $login, $link, $name, $first, $after, $last, $before)',
'$runtimeType',
);
final variables = SearchUsersArguments(
num: num,
login: login,
directLink: link,
name: name,
first: first,
after: after,
last: last,
before: before,
);
QueryResult res = await client.query(
QueryOptions(
operationName: 'SearchUsers',
document: SearchUsersQuery(variables: variables).document,
variables: variables.toJson(),
),
);
return SearchUsers$Query.fromJson(res.data!);
}