-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Querying over composite key #664
Comments
There are various ways to solve this. The easiest, but not very space efficient, would be to create a "reverse" A better / proper way would be to create an index of
That can be done using the first range query you mention, extended or composed by a range query over the spender index (or the other map).
Cool. There are some examples of using indexes in the storage-plus README.md. That should be up-to-date. Please shoot us a message if you find some inconsistent or outdated info there or elsewhere. |
Thx for the replay! /// By example, for a 2-tuple And the same way you can do |
Those "suffix" thingies are for annotating the deserialisation type of the keys, not ranging. Perhaps we should clarify that in the docs. What you propose is cool, but tantamount to using indexes. Need to think more about it, but I think it would require to create and maintain those indexes, just for providing the suffix queries; which is not very convenient. |
I will give a shot on the multi-index then, thanks again! |
Hi, There is no logical OR statement possible while querying storage, is this by design or is it a possible feature Sorry if these questions are uber simple and I'm taking off your development time guys 😄 |
Glad to hear that.
This can be done manually, by combining two queries. I don't think we'll add that, as the storage-plus API is already crowded. But open an issue if you want, detailing your use case.
Yes, that is one of the outstanding things we want to improve. There's an open issue for it: #531.
With
The value is that if you want to use the primary key in some way, it's already deserialised for you. That is particularly useful with composite keys. The default of
Good questions. Glad that it worked for you. |
Thanks a lot for the answers, hope to contribute in some way in the near future. 😄 |
Hi, I was wondering if my thinking is wrong or that's how it's supposed to work, but
While querying the composite key:
pub const STATE: Map<(Addr,Addr),State>
While using
.prefix(addr)
I'm able to query only by the first element of the composite key.
I have two addresses as composite key, let's say (owner, spender)
I'd like to write a query "give me all records for the owner with such address" (that's easy).
But also "give me all records for spender with such address" (this is where I'm lost).
Also "give all records where such address is either owner or spender" would also be great.
Is there a way to query both/second-part only?
Digging through issues on git and documentation didn't find an answer
I'm using the latest cosmwasm storage plus
The text was updated successfully, but these errors were encountered: