# `Bolty`

Bolt driver for Elixir.

# `basic_auth`

```elixir
@type basic_auth() :: {:username, String.t()} | {:password, String.t() | nil}
```

The basic authentication scheme relies on traditional username and password

* `:username` - Username (default: `BOLT_USER` env variable)

* `:password` - Password (default: `BOLT_PWD` env variable, then `nil`)

# `conn`

```elixir
@type conn() :: DBConnection.conn()
```

# `option`

```elixir
@type option() :: %{
  bookmarks: list(),
  mode: String.t(),
  db: String.t() | nil,
  tx_metadata: map() | nil
}
```

# `start_option`

```elixir
@type start_option() ::
  {:uri, String.t()}
  | {:hostname, String.t()}
  | {:port, :inet.port_number()}
  | {:scheme, :inet.port_number()}
  | {:versions, [float()]}
  | {:auth, basic_auth()}
  | {:user_agent, String.t()}
  | {:notifications_minimum_severity, String.t()}
  | {:notifications_disabled_categories, [String.t()]}
  | {:ssl, boolean()}
  | {:ssl_opts, [:ssl.tls_client_option()]}
  | {:connect_timeout, timeout()}
  | {:socket_options, [:gen_tcp.connect_option()]}
  | DBConnection.start_option()
```

# `child_spec`

```elixir
@spec child_spec([start_option()]) :: :supervisor.child_spec()
```

Returns a supervisor child specification for a DBConnection pool.

# `query`

Executes a single query and returns the result.

## Examples

```elixir
{:ok, result} = Bolty.query(conn, "MATCH (n) RETURN n LIMIT 1")

{:ok, people} = Bolty.query(conn, "MATCH (n:PERSON) RETURN n", %{}, [db: "mydb"])
```

# `query!`

Executes a single query and returns the result.

## Examples

```elixir
result = Bolty.query!(conn, "MATCH (n) RETURN n LIMIT 1")

people = Bolty.query!(conn, "MATCH (n:PERSON) RETURN n", %{}, [db: "mydb"])
```

# `query_many`

# `query_many!`

# `rollback`

```elixir
@spec rollback(DBConnection.t(), any()) :: no_return()
```

# `start_link`

```elixir
@spec start_link([start_option()]) :: {:ok, pid()} | {:error, Bolty.Error.t()}
```

Starts the connection process and connects to a Bolt/Neo4j server.

## Options

* `:uri` - Connection URI. The uri configuration takes priority over the hostname, port, and scheme options.
 URI has the form: `<SCHEME>://<HOST>[:<PORT>[?policy=<POLICY-NAME>]]`

* `:hostname` - Server hostname (default: `BOLT_HOST` env variable, then `"localhost"`)

* `:port` - Server port (default: `BOLT_TCP_PORT` env variable, then `7687`)

* `:scheme` - Is one among neo4j, neo4j+s, neo4j+ssc, bolt, bolt+s, bolt+ssc (default: bolt+s).

* `:versions` - List of bolt versions you want to be negotiated with the server.

* `:auth` - The basic authentication scheme

* `:user_agent` - Optionally override the default user agent name. (Default: 'bolty/<version>')

* `:notifications_minimum_severity` - Set the minimum severity for notifications the server
 should send to the client. Disabling severities allows the server to skip analysis for those,
which can speed up query execution. (default: nil) _New in neo4j v5.7 and Bolt v5.2_

* `:notifications_disabled_categories` - Set categories of notifications the server should not
 send to the client. Disabling categories allows the server to skip analysis for those, which
can speed up query execution. (default: nil) _New in neo4j v5.7 and Bolt v5.2_

* `:connect_timeout` - Socket connect timeout in milliseconds (default:
    `15_000`)

* `:ssl` - Set to `true` if SSL should be used (default: `true`)

* `:ssl_opts` - A list of SSL options, see `:ssl.connect/2` (default: `[verify: :verify_none]`)

The given options are passed down to DBConnection, some of the most commonly used ones are
 documented below:

* `:after_connect` - A function to run after the connection has been established, either a
    1-arity fun, a `{module, function, args}` tuple, or `nil` (default: `nil`)

* `:pool` - The pool module to use, defaults to built-in pool provided by DBconnection

* `:pool_size` - The size of the pool

# `transaction`

```elixir
@spec transaction(
  conn(),
  (DBConnection.t() -&gt; result),
  [DBConnection.option()],
  option()
) ::
  {:ok, result} | {:error, any()}
when result: var
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
