Skip to content

Commit

Permalink
Small docs improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide committed Jul 1, 2023
1 parent 866e0ea commit 1bfaad6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 7 additions & 5 deletions lib/xandra/cluster.ex
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ defmodule Xandra.Cluster do
alias Xandra.{Batch, ConnectionError, Prepared, RetryStrategy}
alias Xandra.Cluster.{ControlConnection, LoadBalancingPolicy, Host}

@typedoc """
A Xandra cluster.
"""
@type cluster :: GenServer.server()

@default_port 9042
Expand Down Expand Up @@ -499,7 +502,7 @@ defmodule Xandra.Cluster do
If the function is successful, the prepared query is returned directly
instead of in an `{:ok, prepared}` tuple like in `prepare/3`.
"""
@spec prepare!(cluster, Xandra.statement(), keyword) :: Xandra.Prepared.t() | no_return
@spec prepare!(cluster, Xandra.statement(), keyword) :: Xandra.Prepared.t()
def prepare!(cluster, statement, options \\ []) do
case prepare(cluster, statement, options) do
{:ok, result} -> result
Expand Down Expand Up @@ -548,9 +551,8 @@ defmodule Xandra.Cluster do
Same as `execute/3` but returns the result directly or raises in case of errors.
"""
@spec execute!(cluster, Xandra.statement() | Xandra.Prepared.t(), Xandra.values()) ::
Xandra.result() | no_return
@spec execute!(cluster, Xandra.Batch.t(), keyword) ::
Xandra.Void.t() | no_return
Xandra.result()
@spec execute!(cluster, Xandra.Batch.t(), keyword) :: Xandra.Void.t()
def execute!(cluster, query, params_or_options \\ []) do
case execute(cluster, query, params_or_options) do
{:ok, result} -> result
Expand All @@ -562,7 +564,7 @@ defmodule Xandra.Cluster do
Same as `execute/4` but returns the result directly or raises in case of errors.
"""
@spec execute(cluster, Xandra.statement() | Xandra.Prepared.t(), Xandra.values(), keyword) ::
Xandra.result() | no_return
Xandra.result()
def execute!(cluster, query, params, options) do
case execute(cluster, query, params, options) do
{:ok, result} -> result
Expand Down
4 changes: 3 additions & 1 deletion lib/xandra/page.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ defmodule Xandra.Page do
## 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"
IO.puts("Read user with name #{name} (age #{age}) out of the database")
end)
"""
Expand Down

0 comments on commit 1bfaad6

Please sign in to comment.