ElectionResource (client.election)¶
Endpoints: • election.getElections (cursor-paginated)
.collect_all()¶
Fetch all items across all pages concurrently using parallel time-slicing.
Signature¶
await client.election.collect_all(**kwargs: 'typing.Any') -> 'list[Election]'
Parameters¶
| Name | Type | Default |
|---|---|---|
kwargs |
Any |
Required |
Return Models¶
Election¶
An election event in a country.
| Field | Type | Required |
|---|---|---|
_id |
string |
Optional |
__v |
integer |
Optional |
country |
string |
Optional |
electedCandidates |
array[string] |
Optional |
isActive |
boolean |
Optional |
type |
string |
Optional |
candidates |
array[ElectionCandidate] |
Optional |
votesStartAt |
string |
Optional |
votesEndAt |
string |
Optional |
votesCount |
integer |
Optional |
electedCount |
integer |
Optional |
createdAt |
string |
Optional |
status |
string |
Optional |
votes |
object |
Optional |
ElectionCandidate¶
A candidate in an election.
| Field | Type | Required |
|---|---|---|
user |
string |
Optional |
voteCount |
integer |
Optional |
article |
string |
Optional |
party |
string |
Optional |
isElected |
boolean |
Optional |
.get_by_country()¶
Convenience: fetch all elections in a given country.
Signature¶
await client.election.get_by_country(country_id: 'str') -> 'list[Election]'
Parameters¶
| Name | Type | Default |
|---|---|---|
country_id |
str |
Required |
Return Models¶
Election¶
An election event in a country.
| Field | Type | Required |
|---|---|---|
_id |
string |
Optional |
__v |
integer |
Optional |
country |
string |
Optional |
electedCandidates |
array[string] |
Optional |
isActive |
boolean |
Optional |
type |
string |
Optional |
candidates |
array[ElectionCandidate] |
Optional |
votesStartAt |
string |
Optional |
votesEndAt |
string |
Optional |
votesCount |
integer |
Optional |
electedCount |
integer |
Optional |
createdAt |
string |
Optional |
status |
string |
Optional |
votes |
object |
Optional |
ElectionCandidate¶
A candidate in an election.
| Field | Type | Required |
|---|---|---|
user |
string |
Optional |
voteCount |
integer |
Optional |
article |
string |
Optional |
party |
string |
Optional |
isElected |
boolean |
Optional |
.get_paginated()¶
Get elections (cursor-paginated), optionally filtered by country.
Args:
country_id: Filter to elections in this country.
direction: "forward" (default) or "backward" pagination.
Signature¶
await client.election.get_paginated(*, country_id: 'str | None' = None, limit: 'int' = 20, cursor: 'str | None' = None, direction: 'str | None' = None, auto_items: 'bool' = False, max_pages: 'int | float' = inf, cursor_end: 'str | None' = None) -> 'CursorPage[Election] | AsyncIterator[Election]'
Parameters¶
| Name | Type | Default |
|---|---|---|
country_id |
str |
None |
limit |
int |
20 |
cursor |
str |
None |
direction |
str |
None |
auto_items |
bool |
False |
max_pages |
int | float |
inf |
cursor_end |
str |
None |
Return Models¶
CursorPage[Election]¶
| Field | Type | Required |
|---|---|---|
_id |
string |
Optional |
__v |
integer |
Optional |
items |
array[Election] |
Required |
nextCursor |
string |
Optional |
hasMore |
boolean |
Optional |
Election¶
An election event in a country.
| Field | Type | Required |
|---|---|---|
_id |
string |
Optional |
__v |
integer |
Optional |
country |
string |
Optional |
electedCandidates |
array[string] |
Optional |
isActive |
boolean |
Optional |
type |
string |
Optional |
candidates |
array[ElectionCandidate] |
Optional |
votesStartAt |
string |
Optional |
votesEndAt |
string |
Optional |
votesCount |
integer |
Optional |
electedCount |
integer |
Optional |
createdAt |
string |
Optional |
status |
string |
Optional |
votes |
object |
Optional |
ElectionCandidate¶
A candidate in an election.
| Field | Type | Required |
|---|---|---|
user |
string |
Optional |
voteCount |
integer |
Optional |
article |
string |
Optional |
party |
string |
Optional |
isElected |
boolean |
Optional |
.invalidate_cache()¶
Clear the SWR cache for all resources.
Signature¶
await client.election.invalidate_cache() -> 'None'