how can i query the storage
via .entries
when i know the list of the IDs which are used to store the data?
snippet from decl_storage
/// PoE Proofs
Proofs get(fn proofs): map hasher(blake2_128_concat) GenericId=> ProofInfo<Proof, T::AccountId, T::BlockNumber>;
typescript code where i am trying to get the only few entries
type IncomingParam = [StorageKey, ProofInfo]
type SnGenericIds = GenericId[]
export async function getAll (
items: SnGenericIds = []
): Promise<IncomingParam[]> {
const api = getApi()
return await api.query.poe.proofs.entries(items)
}
// items is [ '0x6261666b313332313365616465617364' ]
when i use the polkadot.js app in the browser and pass that ID i get the record and only one, the above TS code returns ALL the records, i've checked https://polkadot.js.org/api/start/api.query.other.html#map-keys-entries and if i understand correctly above code should. work
i know of the multi
but i'd like to use this method to get all or some, is that even possible?
the .entries(args)
is only possible to use and filter with the double_map
where the args
is a single string that matches the first argument of the double_map
The rust code above does not have filtering thus the RPC and the API will retrieve all entries.
so the rust code would be following:
/// PoE Proofs
pub Proofs get(fn proofs): double_map hasher(blake2_128_concat) GenericId, hasher(twox_64_concat) T::AccountId => ProofInfo<Proof, T::AccountId, T::BlockNumber>;
this allows filtering using the following approach
api.query.poe.proofs.entries('0x1231233132312')
Additional info can be found here