template Thing
with
description: Text
smallThingKeys: [SmallThingKey]
...
where SmallThingKey is a contract key to a SmallThing. Thing and SmallThing contain data that is to be shown in the user interface. When fetching the SmallThings, is it possible to submit a single query (containing all the smallThingKeys) and receive the SmallThings in one result? I know this can be done by making multiple separate queries, but this would not be ideal given that I am trying to render a table of many Things.
Thanks again for the help.
Alex
(Ideal solution would use the @daml/ledger JS library. That being said, I am considering writing some Java middleware.)
controller c can LookupMany : Update [ (ContractId SmallThing, SmallThing) ] with smallThingKeys =
do mapA fetchByKey smallThingKeys
(n.b. untested)
This uses mapA from Traversable. It allows you to sequence a [ Update ] (i.e. your key lookups) into an Update []. This means, that the transaction will fail in whole if one of the lookups fail; otherwise it will return all the results in a list.
Thanks for the help everyone, I take it there is no way to do this by standard fetch ATM.
@Luciano so execute a choice when wanting to view all the SmallThings? Looks interesting.
TBH ideal solution would be a fetch by multiple contract keys; not stream because I don’t think it’d be good to open many web sockets for a table of many Things.