Getting all data from a LookupMap #833
-
I read in the documentation that LookupMap doesn't support iteration, which is fine, I guess this is the price of being efficient. But is there no way at all to get the stored data from a LookupMap? I'm trying to update some data stored in a LookupMap, but I can only reach data by using a specific key. What about contract storage migrations? How would you migrate a LookupMap to something else? I tried to change it's type via a migration to something that supports iteration (e.g. TreeMap), but again, to move every value from the old collection to the new one, I need to iterate through it... I thought about getting and inserting the values one by one, but there's no way to get the existing keys either 😢 As a last resort I even thought about iterating through the whole key-space, but the key is unfortunately a Is there a workaround for this? Can I get the raw data somehow from the underlying storage? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Currently there is a near-cli command (and RPC method) to get the state of a contract from a prefix: https://github.com/near/near-cli/blob/master/commands/view-state.js However, this suffers from a configuration for NEAR nodes that limits this to contracts with state less than 50 kb if remember correctly, so likely won't work. I haven't tried, but there are now other RPC providers which might lossen that requirement or per happens with the |
Beta Was this translation helpful? Give feedback.
Currently there is a near-cli command (and RPC method) to get the state of a contract from a prefix: https://github.com/near/near-cli/blob/master/commands/view-state.js
However, this suffers from a configuration for NEAR nodes that limits this to contracts with state less than 50 kb if remember correctly, so likely won't work.
I haven't tried, but there are now other RPC providers which might lossen that requirement or per happens with the
dev console
where Pagoda requires you to provide an API key.