Current section
Files
Jump to
Current section
Files
lib/subaru/store.ex
defmodule Subaru.Store do
@moduledoc """
Thin facade that dispatches storage operations to the configured adapter.
This module isolates the rest of the code base from the concrete
storage implementation. By default the `Subaru.Store.Mnesia` adapter is
used, but this can be changed via the `:subaru` application environment:
config :subaru, :store, Subaru.Store.Mnesia
"""
@adapter Application.compile_env(:subaru, :store, Subaru.Store.Mnesia)
# Schema operations
def init(options \\ []), do: @adapter.init(options)
def stop(), do: @adapter.stop()
def clear(nodes \\ [node()]), do: @adapter.clear(nodes)
# Vertex operations
def get_vertex(id), do: @adapter.get_vertex(id)
def put_vertex(id, props), do: @adapter.put_vertex(id, props)
# Edge operations
def get_edges(src_id, type), do: @adapter.get_edges(src_id, type)
def put_edge(src_id, type, dst_id, props), do: @adapter.put_edge(src_id, type, dst_id, props)
# Batch and transaction operations
def write_batch(actions), do: @adapter.write_batch(actions)
def transaction(fun), do: @adapter.transaction(fun)
# Query operations
def iterate(prefix, opts \\ []), do: @adapter.iterate(prefix, opts)
def snapshot(fun), do: @adapter.snapshot(fun)
# Backup/restore operations
def backup(path), do: @adapter.backup(path)
def restore(path), do: @adapter.restore(path)
def export(), do: @adapter.export()
end