View Source Ravix.Documents.Session.State (ravix v0.6.3)
A session state representation
fields
Fields
- store: The Store module for which the session belongs
- session_id: The uuid of this session
- database: for which database this session belongs
- conventions: Document conventions for this session
- documents_by_id: Loaded documents in this session
- defer_commands: Commands that will be deferred when the session is persisted
- deleted_entities: Documents that will be deleted when the session is persisted
- running_queries: RQL queries running for this session
- last_session_call: When the last session call was executed
- number_of_requests: Number os requests that will be executed at this session persistence
Link to this section Summary
Functions
Clear the deferred commands from the session
Clear the deleted entities from the session
Fetches a document from the session
Increments the number of requests count
Marks a document to be deleted
Adds a document to the session
Updates the last session call time
Updates the session with RavenDB responses
Link to this section Types
@type t() :: %Ravix.Documents.Session.State{ conventions: Ravix.Documents.Conventions.t(), database: String.t(), defer_commands: list(), deleted_entities: list(), documents_by_id: map(), last_session_call: DateTime.t() | nil, number_of_requests: non_neg_integer(), running_queries: map(), session_id: bitstring(), store: atom() | nil }
Link to this section Functions
Clear the deferred commands from the session
Clear the deleted entities from the session
Fetches a document from the session
paremeters
Paremeters
- state: the session state
- document_id: the document id
returns
Returns
{:ok, document}
{:error, :document_not_found}
if there is no document with the informed id on the session
Increments the number of requests count
parameters
Parameters
- session_state: the session state
returns
Returns
- updated session state
Marks a document to be deleted
parameters
Parameters
- state: the session state
- document_id: the document id to be deleted
returns
Returns
{:ok, state}
{:error, :document_already_deferred}
if the document id is in a deferred command{:error, :document_deleted}
if the document is already marked for delete{:error, :document_not_in_session}
is the document is not loaded in the session
Link to this function
register_document(state, key, entity, change_vector, original_document \\ nil)
View SourceAdds a document to the session
parameters
Parameters
- state: the session state
- key: the key where the document will be related to
- entity: the document to be persisted
- change_vector: the concurrency change vector string
- original_document: if it's a update, this is the document before the change
returns
Returns
{:ok, updated_state}
{:error, :document_already_deferred}
if the document id is in a deferred command{:error, :document_deleted}
if the document is marked for delete
Updates the last session call time
parameters
Parameters
- session_state: the session state
returns
Returns
- updated session state
@spec update_session(t(), maybe_improper_list()) :: t()
Updates the session with RavenDB responses
parameters
Parameters
- session_state: the session state
- updates: List of updates to be applied to the session
returns
Returns
- the updated session