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
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
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 section Functions
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
.
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"
get_content_type(t()) :: {:ok, content_type() | :undefined} | {:error, ExRiak.SiblingsError.t()}
Returns the content type of the value if there are no siblings.
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.
Returns a list of content types for all siblings.
Returns the contents (a list of {metadata, value
tuples) for this object.
get_metadata(t()) :: {:ok, metadata()} | {:error, ExRiak.SiblingsError.t()}
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.
get_update_content_type(t()) :: {:ok, content_type() | :undefined} | {:error, ExRiak.SiblingsError.t()}
Returns the content type of the update value.
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.
get_update_metadata(t()) :: {:ok, metadata()} | {:error, ExRiak.SiblingsError.t()}
Returns the updated metadata for this object.
Returns the updated metadata for this object, erroring out if there are siblings.
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.
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.
get_value(t()) :: {:ok, value()} | {:error, ExRiak.SiblingsError.t() | ExRiak.NoValueError.t() | ExRiak.DecodingError.t()}
Returns the value of the object if there are no siblings.
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.
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
.
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
.
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
.
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
.
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"
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>>
Returns true if this object has more than one sibling.
update_content_type(t(), content_type()) :: t()
Sets the updated content type of an object.
Sets the updated metadata of an object.
Sets the updated value of an object.
update_value(t(), value(), content_type()) :: t()
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.
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
.