-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.mo
More file actions
31 lines (21 loc) · 738 Bytes
/
main.mo
File metadata and controls
31 lines (21 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import Map "mo:base/HashMap";
import Text "mo:base/Text";
import Principal "mo:base/Principal";
shared(msg) actor class DataList() {
let owner = msg.caller;
type Name = Text;
type Data = Text;
let data = Map.HashMap<Name, Data>(0, Text.equal, Text.hash);
public shared(msg) func insert(name : Name, entry : Data): async () {
let userId = Principal.toText(msg.caller);
data.put(userId#name, entry);
};
public shared(msg) func lookup(name : Name) : async ?Data {
let userId = Principal.toText(msg.caller);
data.get(userId#name)
};
// Return the principal identifier of the caller of this method.
public shared (msg) func whoami() : async Text {
return Principal.toText(msg.caller);
};
}