Getting key of the map in erlang

Sanket Agrawal sanket.agrawal at
Thu Apr 28 12:02:47 EDT 2016

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
<>, 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the riak-users mailing list