function initializeDirectCanDBPartitionClient(canisterId: Principal)
{
const host = isLocal ? "http://127.0.0.1:8000" : "https://ic0.app";
const agent = new HttpAgent({ host });
return Actor.createActor(CanDBPartitionIDL, { agent, canisterId });
};
...
const client = initializeDirectCanDBPartitionClient(obj.itemRef.canister);
obj.item = await client.getItem(BigInt(obj.itemRef.id)) as any;
produces
Uncaught (in promise) Error: Call failed:
Canister: a3shf-5eaaa-aaaaa-qaafa-cai
Method: getItem (query)
"Status": "rejected"
"Code": "CanisterError"
"Message": "IC0503: Canister a3shf-5eaaa-aaaaa-qaafa-cai trapped explicitly: Array index out of bounds"
at caller (index.js:184:27)
at async ItemData.create (index.js:78705:20)
But
func _getAttribute(options: CanDB.GetOptions, subkey: Text): ?Entity.AttributeValue {
Debug.print("ITEM-1: "); // FIXME: Remove.
let all = CanDB.get(db, options);
Debug.print("ITEM0: " # debug_show(all)); // FIXME: Remove.
do ? { RBT.get(all!.attributes, Text.compare, subkey)! };
};
...
public query func getItem(itemId: Nat): async ?lib.Item {
let data = _getAttribute({sk = "i/" # Nat.toText(itemId)}, "i");
Debug.print("ITEM: " # debug_show(data)); // FIXME: Remove.
do ? { lib.deserializeItem(data!) };
};
should output at least ITEM-1:
, which however does not appear in the logs of dfx start
.
Why the error?!