Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: demergent-labs/azle
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 16b7d39b616aca14aad47e13755928f756e24c4a
Choose a base ref
..
head repository: demergent-labs/azle
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 654da5e8c4706ce4a6ca6db46813ef7ea365edce
Choose a head ref
Showing with 3 additions and 33 deletions.
  1. +3 −33 examples/query/src/index.ts
36 changes: 3 additions & 33 deletions examples/query/src/index.ts
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';
})
});