Skip to content

samlinux-development/map-vector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Map and Vector adventure

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.

Installation

mops install 
dfx deploy 

Usage

# 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

About

Example for stable Map and Vector data types

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages