ExRiak v0.4.0 ExRiak.Object View Source

Wrapper around :riakc_obj API.

Link to this section Summary

Types

The binary value to use as this object’s key

t()

Functions

Returns the bucket for this object

Returns the bucket type for this object

Returns the content type of the value if there are no siblings

Returns the content type for the value, erroring out if there are siblings

Returns a list of content types for all siblings

Returns the contents (a list of {metadata, value tuples) for this object

Returns the metadata for the object if there are no siblings

Returns the metadata for the object, erroring out if there are siblings

Return a list of metadata values for the object

Returns the content type of the update value

Returns the content type for the update value, erroring out if there are siblings

Returns the updated metadata for this object

Returns the updated metadata for this object, erroring out if there are siblings

Returns the update value of this object if there are no siblings

Returns the update value for the object, erroring out if there are siblings

Returns the value of the object if there are no siblings

Returns the value for the object, erroring out if there are siblings

Returns a list of values for this object

Returns the key for this object

Constructor for new riak_client objects

Constructor for new riak client objects with an update value

Constructor for new riak client objects with an update value and content type

Returns only the bucket name for this object

Set the vector clock for this object

Returns true if this object has more than one sibling

Sets the updated content type of an object

Sets the updated metadata of an object

Sets the updated value of an object

Sets the updated value and content type of an object

Returns the number of values (siblings) of an object

Returns the vector clock for this object

Link to this section Types

Link to this type bucket_locator() View Source
bucket_locator() :: ExRiak.bucket_locator()
Link to this type key() View Source
key() :: ExRiak.key() | :undefined

The binary value to use as this object’s key.

Can also be set to :undefined to have riak generate a key when the object is stored. See ExRiak.PBSocket.put/2.

Link to this type value() View Source
value() :: term()

Link to this section Functions

Link to this function add_secondary_index(metadata, index) View Source

Returns the bucket for this object.

Example

iex(1)> obj = Object.new("bucket", "key")
...(1)> Object.bucket(obj)
"bucket"

iex(2)> obj = Object.new({"bucket-type","bucket"}, "key")
...(2)> Object.bucket(obj)
{"bucket-type","bucket"}

See :riakc_obj.bucket/1.

Link to this function bucket_type(obj) View Source
bucket_type(t()) :: ExRiak.bucket_type() | :undefined

Returns the bucket type for this object.

Example

iex(1)> obj = Object.new("bucket", "key")
...(1)> Object.bucket_type(obj)
:undefined

iex(2)> obj = Object.new({"bucket-type","bucket"}, "key")
...(2)> Object.bucket_type(obj)
"bucket-type"

See :riakc_obj.bucket_type/1.

Link to this function clear_secondary_indexes(metadata) View Source
Link to this function clear_user_metadata_entries(metadata) View Source
Link to this function delete_secondary_index(metadata, secondary_index_id) View Source
Link to this function delete_user_metadata_entry(metadata, metadata_key) View Source
Link to this function get_content_type(obj) View Source
get_content_type(t()) ::
  {:ok, content_type() | :undefined} |
  {:error, ExRiak.SiblingsError.t()}

Returns the content type of the value if there are no siblings.

See :riakc_obj.get_content_type/1.

Link to this function get_content_type!(obj) View Source
get_content_type!(t()) :: content_type() | :undefined | no_return()

Returns the content type for the value, erroring out if there are siblings.

If there are no siblings, the content type is returned. If there are siblings, a ExRiak.SiblingsError exception is raised.

See :riakc_obj.get_content_type/1.

Link to this function get_content_types(obj) View Source
get_content_types(t()) :: [content_type()]

Returns a list of content types for all siblings.

See :riakc_obj.get_content_types/1.

Link to this function get_contents(obj) View Source
get_contents(t()) :: [{metadata(), value()}]

Returns the contents (a list of {metadata, value tuples) for this object.

See :riakc_obj.get_contents/1.

Link to this function get_metadata(obj) View Source
get_metadata(t()) ::
  {:ok, metadata()} |
  {:error, ExRiak.SiblingsError.t()}

Returns the metadata for the object if there are no siblings.

See :riakc_obj.get_metadata/1.

Link to this function get_metadata!(obj) View Source
get_metadata!(t()) :: metadata() | no_return()

Returns the metadata for the object, erroring out if there are siblings.

See :riakc_obj.get_metadata/1.

Link to this function get_metadatas(obj) View Source
get_metadatas(t()) :: [metadata()]

Return a list of metadata values for the object.

See :riakc_obj.get_metadatas/1.

Link to this function get_secondary_index(metadata, secondary_index_id, default \\ nil) View Source
Link to this function get_secondary_indexes(metadata) View Source
Link to this function get_update_content_type(obj) View Source
get_update_content_type(t()) ::
  {:ok, content_type() | :undefined} |
  {:error, ExRiak.SiblingsError.t()}

Returns the content type of the update value.

See :riakc_obj.get_update_content_type/1.

Link to this function get_update_content_type!(obj) View Source
get_update_content_type!(t()) ::
  content_type() |
  :undefined |
  no_return()

Returns the content type for the update value, erroring out if there are siblings.

If there are no siblings, the content type is returned. If there are siblings, a ExRiak.SiblingsError exception is raised.

See :riakc_obj.get_update_content_type/1.

Link to this function get_update_metadata(obj) View Source
get_update_metadata(t()) ::
  {:ok, metadata()} |
  {:error, ExRiak.SiblingsError.t()}

Returns the updated metadata for this object.

See :riakc_obj.get_update_metadata/1.

Link to this function get_update_metadata!(obj) View Source
get_update_metadata!(t()) :: metadata()

Returns the updated metadata for this object, erroring out if there are siblings.

See :riakc_obj.get_update_metadata/1.

Link to this function get_update_value(obj) View Source
get_update_value(t()) ::
  {:ok, value()} |
  {:error, ExRiak.SiblingsError.t() | ExRiak.NoValueError.t() | ExRiak.DecodingError.t()}

Returns the update value of this object if there are no siblings.

See :riakc_obj.get_update_value/1.

Link to this function get_update_value!(obj) View Source
get_update_value!(t()) :: value() | no_return()

Returns the update value for the object, erroring out if there are siblings.

If there are no siblings, the corresponding value is returned. If there are siblings, a ExRiak.SiblingsError exception is raised. If there is no value, a ExRiak.NoValueError exception is raised.

See :riakc_obj.get_update_value/1.

Link to this function get_user_metadata_entries(metadata) View Source
Link to this function get_user_metadata_entry(metadata, metadata_key, default \\ nil) View Source

Returns the value of the object if there are no siblings.

See :riakc_obj.get_value/1.

Link to this function get_value!(obj) View Source
get_value!(t()) :: value() | no_return()

Returns the value for the object, erroring out if there are siblings.

If there are no siblings, the corresponding value is returned. If there are siblings, a ExRiak.SiblingsError exception is raised. If there is no value, a ExRiak.NoValueError exception is raised.

See :riakc_obj.get_value/1.

Link to this function get_values(obj) View Source
get_values(t()) :: [value() | ExRiak.DecodingError.t()]

Returns a list of values for this object.

See :riakc_obj.values/1.

Returns the key for this object.

Example

iex(1)> obj = Object.new("bucket", "key")
...(1)> Object.key(obj)
"key"

See :riakc_obj.key/1.

Link to this function new(bucket_locator, key) View Source
new(bucket_locator(), key()) :: t() | no_return()

Constructor for new riak_client objects.

Raises an ArgumentError with an invalid bucket locator.

See :riakc_obj.new/2.

Link to this function new(bucket_locator, key, value) View Source
new(bucket_locator(), key(), value()) :: t() | no_return()

Constructor for new riak client objects with an update value.

Raises an ArgumentError with an invalid bucket locator.

See :riakc_obj.new/3.

Link to this function new(bucket_locator, key, value, content_type) View Source
new(bucket_locator(), key(), value(), content_type()) ::
  t() |
  no_return()

Constructor for new riak client objects with an update value and content type.

Raises an ArgumentError with an invalid bucket locator.

See :riakc_obj.new/4.

Link to this function only_bucket(obj) View Source
only_bucket(t()) :: ExRiak.bucket()

Returns only the bucket name for this object

Example

iex(1)> obj = Object.new("bucket", "key")
...(1)> Object.only_bucket(obj)
"bucket"

iex(2)> obj = Object.new({"bucket-type","bucket"}, "key")
...(2)> Object.only_bucket(obj)
"bucket"

See :riakc_obj.only_bucket/1.

Link to this function set_secondary_index(metadata, index) View Source
Link to this function set_user_metadata_entry(metadata, metadata_entry) View Source
Link to this function set_vclock(obj, vclock) View Source
set_vclock(t(), vclock()) :: t()

Set the vector clock for this object.

Examples

iex(1)> Object.new("bucket", "key")
...(1)> |> Object.set_vclock(<<92, 73, 34>>)
...(1)> |> Object.vclock()
<<92, 73, 34>>

iex(2)> :riakc_obj.new("bucket", "key")
...(2)> |> Object.set_vclock(<<107, 206>>)
...(2)> |> :riakc_obj.vclock()
<<107, 206>>

See :riakc_obj.set_vclock/2.

Link to this function siblings?(obj) View Source
siblings?(t()) :: boolean()

Returns true if this object has more than one sibling.

See :riakc_obj.value_count/1.

Link to this function update_content_type(obj, content_type) View Source
update_content_type(t(), content_type()) :: t()

Sets the updated content type of an object.

See :riakc_obj.update_content_type/2.

Link to this function update_metadata(obj, metadata) View Source
update_metadata(t(), metadata()) :: t()

Sets the updated metadata of an object.

See :riakc_obj.update_metadata/2.

Link to this function update_value(obj, error) View Source
update_value(t(), value()) :: t()

Sets the updated value of an object.

See :riakc_obj.update_value/2.

Link to this function update_value(obj, error, content_type) View Source
update_value(t(), value(), content_type()) :: t()

Sets the updated value and content type of an object.

See :riakc_obj.update_value/3.

Link to this function value_count(obj) View Source
value_count(t()) :: non_neg_integer()

Returns the number of values (siblings) of an object.

See :riakc_obj.value_count/1.

Link to this function vclock(obj) View Source
vclock(t()) :: vclock() | :undefined

Returns the vector clock for this object.

Examples

iex(1)> obj = Object.new("bucket", "key")
...(1)> Object.vclock(obj)
:undefined

iex(2)> :riakc_obj.new("bucket", "key")
...(2)> |> :riakc_obj.set_vclock(<<107, 206>>)
...(2)> |> Object.vclock()
<<107, 206>>

iex(3)> Object.new("bucket", "key")
...(3)> |> Object.set_vclock(<<105, 207>>)
...(3)> |> Object.vclock()
<<105, 207>>

See :riakc_obj.vclock/1.