ArtefactoryNeo4j (ArtefactoryNeo4j v0.3.0)

Copy Markdown View Source

Neo4j persistence for %Artefact{} structs.

Provides read/write access to a named Neo4j database (via Bolty and DozerDB) and database lifecycle management — create, drop, stop, start.

Each entity (Me, Mob, a native You) has its own named database. The db: option on every query routes to the correct database without needing separate connections.

Usage

{:ok, conn} = ArtefactoryNeo4j.connect(uri: "bolt://localhost:7688",
                                        auth: [username: "neo4j", password: "password"])

:ok = ArtefactoryNeo4j.create_database(conn, "matt_artefactory")

:ok = ArtefactoryNeo4j.write(conn, artefact, db: "matt_artefactory")

{:ok, artefact} = ArtefactoryNeo4j.fetch(conn, uuid, db: "matt_artefactory")

Summary

Functions

Open a Bolty connection to the Neo4j instance.

Create a named database (DozerDB feature — not available on plain Community). Name is Elixir country (snake_case atom or string) — converted to kebab-case automatically.

Drop a named database. Name follows Elixir convention — converted to kebab-case automatically.

Fetch nodes matching a uuid from the given database.

Start a named database. Name follows Elixir convention — converted to kebab-case automatically.

Stop a named database. Name follows Elixir convention — converted to kebab-case automatically.

Write an artefact to the given database using parameterised MERGE.

Functions

connect(opts)

Open a Bolty connection to the Neo4j instance.

create_database(conn, name)

Create a named database (DozerDB feature — not available on plain Community). Name is Elixir country (snake_case atom or string) — converted to kebab-case automatically.

drop_database(conn, name)

Drop a named database. Name follows Elixir convention — converted to kebab-case automatically.

fetch(conn, uuid, opts \\ [])

Fetch nodes matching a uuid from the given database.

The db: name follows Elixir convention — converted to Neo4j kebab-case automatically. Returns {:ok, rows} where each row is a map of field => %Bolty.Types.Node{} with property keys in snake_case.

start_database(conn, name)

Start a named database. Name follows Elixir convention — converted to kebab-case automatically.

stop_database(conn, name)

Stop a named database. Name follows Elixir convention — converted to kebab-case automatically.

write(conn, artefact, opts \\ [])

Write an artefact to the given database using parameterised MERGE.

The db: name is Elixir country — snake_case atom or string, converted to Neo4j kebab-case automatically. Property keys are converted from snake_case to camelCase at the boundary.