On 28 April 2016 at 17:02, Sanket Agrawal <sanket.agra...@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
> key.
>
> 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?
> http://basho.github.io/riak-erlang-client/riakc_map.html
>
> 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.
>
>
Hi Sanket,

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.

Kind Regards,

Magnus

-- 
Magnus Kessler
Client Services Engineer
Basho Technologies Limited

Registered Office - 8 Lincoln’s Inn Fields London WC2A 3BP Reg 07970431
_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to