View Source Ravix.Documents.Session (ravix v0.0.2)

A stateful session to execute ravendb commands

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Marks the document for deletion

Executes a query into the RavenDB

Fetches the current session state

Callback implementation for GenServer.init/1.

Loads the document from the database to the local session

Persists the session changes to the RavenDB database

Add a document to the session to be created

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

delete(session_id, entity)

View Source
@spec delete(binary(), map()) :: any()

Marks the document for deletion

parameters

Parameters

  • session_id: the session id
  • entity: the document to be deleted

returns

Returns

  • {:ok, updated_state}
  • {:error, cause}
Link to this function

execute_query(query, session_id, method)

View Source
@spec execute_query(any(), binary(), any()) :: any()

Executes a query into the RavenDB

paremeters

Paremeters

  • query: The Ravix.RQL.Query to be executed
  • session_id: the session_id
  • method: The http method
@spec fetch_state(binary()) ::
  {:error, :session_not_found} | {:ok, Ravix.Documents.Session.State.t()}

Fetches the current session state

Link to this function

handle_continue(atom, state)

View Source

Callback implementation for GenServer.handle_continue/2.

Callback implementation for GenServer.init/1.

Link to this function

load(session_id, ids, includes \\ nil, opts \\ nil)

View Source
@spec load(binary(), list() | bitstring(), any(), keyword() | nil) :: any()

Loads the document from the database to the local session

parameters

Parameters

  • session_id: the session_id
  • ids: the document ids to be loaded
  • includes: the document includes path
  • opts: load options

returns

Returns

  • {:ok, results}
  • {:errors, cause}
Link to this function

save_changes(session_id)

View Source
@spec save_changes(binary()) :: any()

Persists the session changes to the RavenDB database

Link to this function

start_link(attr, initial_state)

View Source
@spec start_link(any(), Ravix.Documents.Session.State.t()) ::
  :ignore | {:error, any()} | {:ok, pid()}
Link to this function

store(session_id, entity, key \\ nil, change_vector \\ nil)

View Source
@spec store(binary(), map(), binary() | nil, binary() | nil) :: any()

Add a document to the session to be created

parameters

Parameters

  • session_id: the session id
  • entity: the document to store
  • key: the document key to be used
  • change_vector: the concurrency change vector

returns

Returns

  • {:ok, updated_session}
  • {:error, cause}