Home

Awesome

Boltx

Boltx is an Elixir driver for Neo4j/Bolt Protocol.

Documentation: https://hexdocs.pm/boltx

Features

FeatureImplemented
QuerysYES
TransactionsYES
Stream capabilitiesNO
RoutingNO

Usage

Add :boltx to your dependencies:

def deps() do
  [
    {:boltx, "~> 0.0.6"}
  ]
end

Using the latest version.


opts = [
    hostname: "127.0.0.1",
    auth: [username: "neo4j", password: ""],
    user_agent: "boltxTest/1",
    pool_size: 15,
    max_overflow: 3,
    prefix: :default
]

iex> {:ok, conn} = Boltx.start_link(opts)
{:ok, #PID<0.237.0>}

iex> Boltx.query!(conn, "return 1 as n") |> Boltx.Response.first()
%{"n" => 1}

# Commit is performed automatically if everythings went fine
Boltx.transaction(conn, fn conn ->
  result = Boltx.query!(conn, "CREATE (m:Movie {title: "Matrix"}) RETURN m")
end)

Set it up in an app

Add the configuration to the corresponding files for each environment or to your config/config.ex.

Name of process

The process name must be defined in your configuration

import Config

config :boltx, Bolt,
  uri: "bolt://localhost:7687",
  auth: [username: "neo4j", password: "password"],
  user_agent: "boltxTest/1",
  pool_size: 15,
  max_overflow: 3,
  prefix: :default,
  name: Bolt

Add Boltx to the application's main monitoring tree and let OTP manage it.

# lib/n4_d/application.ex

defmodule N4D.Application do
  @moduledoc false

  use Application

  def start(_type, _args) do
    children = [
      %{
        id: Boltx,
        start: {Boltx, :start_link, [Application.get_env(:boltx, Bolt)] },
      }
    ]

    opts = [strategy: :one_for_one, name: N4D.Supervisor]
    Supervisor.start_link(children, opts)
  end
end

Or

children = [
  {Boltx, Application.get_env(:boltx, Bolt)}
]

Now you can run query with the name you set

iex> Boltx.query!(Bolt, "return 1 as n") |> Boltx.Response.first()
%{"n" => 1}

URI schemes

By default the scheme is bolt+s

URIDescriptionTLSOptions
neo4jUnsecured[]
neo4j+sSecured with full certificate[verify: :verify_none]
neo4j+sscSecured with self-signed certificate[verify: :verify_peer]
boltUnsecured[]
bolt+sSecured with full certificate[verify: :verify_none]
bolt+sscSecured with self-signed certificate[verify: :verify_peer]

Contributing

Getting Started

Neo4j uses the Bolt protocol for communication and query execution. You can find the official documentation for Bolt here: Bolt Documentation.

It is crucial to grasp various concepts before getting started, with the most important ones being:

It is advisable to use the specific terminology from the official documentation and official drivers to ensure consistency with this implementation.

Test

As certain versions of Bolt may be compatible with specific functionalities while others can undergo significant changes, tags are employed to facilitate version-specific testing. Some of these tags include:

By default, all tags are disabled except the :core tag. To enable the tags, it is necessary to configure the following environment variables:

Help script

To simplify test execution, the test-runner.sh script is available. You can find the corresponding documentation here: Help script