This example demonstrate how to use the Map and Vector data types in Motoko, both provided by the Motoko package manager mops.
The Map is stable, meaning its data persists across canister upgrades.
mops install
dfx deploy
# create profile
dfx canister call backend add_profile '("Alice", 20)'
## get your developer principal ID
dfx identity get-principal
>> 4sd6s-xg3ws-aaulg-6h7ju-ntyrc-qpyot-lir4s-abk6o-4s5mn-s7jyv-tqe <<
# add like to profile
# switch to a different dfx user
dfx identity use xxx
# the current user adds a like to the given principal profile if the principal exists
dfx canister call backend add_like_to_profile '(principal "4sd6s-xg3ws-aaulg-6h7ju-ntyrc-qpyot-lir4s-abk6o-4s5mn-s7jyv-tqe")'
# repeat this with different users to add more likes
# get profiles to see the result
dfx canister call backend get_profiles