-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This was accidentally updated in 3b9e879
- Loading branch information
Showing
1 changed file
with
3 additions
and
33 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,7 @@ | ||
import { | ||
Canister, | ||
ic, | ||
Opt, | ||
query, | ||
Record, | ||
StableBTreeMap, | ||
text, | ||
update, | ||
Vec, | ||
Void | ||
} from 'azle'; | ||
|
||
const Entry = Record({ | ||
key: text, | ||
value: text | ||
}); | ||
|
||
let db = StableBTreeMap<text, text>(0); | ||
import { Canister, query, text } from 'azle'; | ||
|
||
export default Canister({ | ||
get: query([text], Opt(text), (key) => { | ||
return db.get(key); | ||
}), | ||
set: update([text, text], Void, (key, value) => { | ||
db.insert(key, value); | ||
}), | ||
setMany: update([Vec(Entry)], Void, (entries) => { | ||
entries.forEach((entry) => { | ||
if (entry.key === 'trap') { | ||
ic.trap('explicit trap'); | ||
} | ||
|
||
db.insert(entry.key, entry.value); | ||
}); | ||
simpleQuery: query([], text, () => { | ||
return 'This is a query function'; | ||
}) | ||
}); |