Getting key of the map in erlang
mkessler at basho.com
Fri Apr 29 11:21:28 EDT 2016
On 28 April 2016 at 17:02, Sanket Agrawal <sanket.agrawal at gmail.com> wrote:
> Not sure if this has been asked before - given a map, how does one go
> about retrieving the key of the map?
> For example, in Riak example for map
> <http://docs.basho.com/riak/kv/2.0.0/developing/data-types/#maps>, a map
> is created with "ahmed_info" key.
> If we were to write a commit hook in Erlang where we want to do some kind
> of action based on the key, it will be helpful to have a way to extract the
> I looked in basho erlang client documentation here for map, but don't see
> any function to extract the key. Perhaps we have to do pattern match to
> extract the key?
> I also see erlang libraries under riak installation (one of them
> "riak_object" is called in "commit hook" example in documentation) - I can
> check there as well if there is online documentation somewhere for them.
> I am thinking of storing user info as immutable maps, something like
> <username>_<info>_<timestamp>, and have an erlang commit hook that updates
> <username>_<info>_<latest> map with the latest entry. For that, we need to
> extract the map key.
The actual association between an Erlang CRDT object and a bucket-type,
bucket, and key has to be done separately from creating the object itself.
Please have a look at the "counters" example on the same page.
I agree that this could be documented better and have mentioned your
question to our documentations team.
Client Services Engineer
Basho Technologies Limited
Registered Office - 8 Lincoln’s Inn Fields London WC2A 3BP Reg 07970431
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the riak-users