Xandra v0.13.0 Xandra.Page View Source
A struct that represents a page of rows.
This struct represents a page of rows that have been returned by the
Cassandra server in response to a query such as SELECT
, but have not yet
been parsed into Elixir values.
This struct implements the Enumerable
protocol and is therefore a stream. It
is through this protocol that a Xandra.Page
struct can be parsed into Elixir
values. The simplest way of getting a list of single rows out of a
Xandra.Page
struct is to use something like Enum.to_list/1
. Each element
emitted when streaming out of a Xandra.Page
struct is a map of string column
names to their corresponding value.
The following fields are public and can be accessed or relied on:
:paging_state
- the current paging state. Its value can be used to check whether more pages are available to fetch after the given page. This is useful when implementing manual paging. See also the documentation forXandra.execute/4
.:tracing_id
- the tracing ID (as a UUID binary) if tracing was enabled, ornil
if no tracing was enabled. See the "Tracing" section inXandra.execute/4
.
Examples
statement = "SELECT name, age FROM users"
%Xandra.Page{} = page = Xandra.execute!(conn, statement, _params = [])
Enum.each(page, fn %{"name" => name, "age" => age} ->
IO.puts "Read user with name #{name} (age #{age}) out of the database"
end)
Link to this section Summary
Link to this section Types
paging_state()
View Source
paging_state() :: binary() | nil
paging_state() :: binary() | nil
t()
View Source
t() :: %Xandra.Page{
columns: [...],
content: list(),
paging_state: paging_state(),
tracing_id: binary() | nil
}
t() :: %Xandra.Page{ columns: [...], content: list(), paging_state: paging_state(), tracing_id: binary() | nil }