Created
November 12, 2014 19:32
-
-
Save rkellermeyer/3e2130aceb25a765b338 to your computer and use it in GitHub Desktop.
Erlang Crud
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(richards_crud). | |
-compile(export_all). | |
new() -> | |
maps:new(). | |
build(Key, Value, Map) -> | |
maps:put(Key, Value, Map). | |
show(Key, Map) -> | |
maps:get(Key, Map). | |
update(Key, Value, Map) -> | |
maps:update(Key,Value,Map). | |
destroy(Map) -> | |
maps:without(maps:keys(Map),Map). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1> c(richards_crud). | |
=> {ok,richards_crud} | |
2> M1 = richards_crud:new(). | |
=> #{} | |
3> richards_crud:build("age", 37, M1). | |
=> {"age" => 37} | |
4> richards_crud:build("gender", "M", M1). | |
=> {"gender" => "M"} | |
Then if I tried to do a maps:find("gender",M1). I would get `error` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment