Skip to content

Commit

Permalink
Merge pull request #500 from CosmWasm/461-uniqueindex-range_de
Browse files Browse the repository at this point in the history
range_de / prefix_de impls for Map-like structs
  • Loading branch information
maurolacy authored Nov 24, 2021
2 parents ba2de19 + b4203be commit bdc9965
Show file tree
Hide file tree
Showing 9 changed files with 1,573 additions and 337 deletions.
18 changes: 18 additions & 0 deletions packages/storage-plus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -613,3 +613,21 @@ Another example that is similar, but returning only the `token_id`s, using the `
.collect();
```
Now `pks` contains `token_id` values (as `Vec<u8>`s) for the given `owner`.

### Index keys deserialization

To deserialize keys of indexes (using the `*_de` functions), there are currently some requirements / limitations:

- For `UniqueIndex`: The primary key (`PK`) type needs to be specified, in order to deserialize the primary key to it.
This generic type comes with a default of `()`, which means that no deserialization / data will be provided
for the primary key. This is for backwards compatibility with the current `UniqueIndex` impl. It can also come handy
in cases you don't need the primary key, and are interested only in the deserialized value.

- For `MultiIndex`: The last element of the index tuple must be specified with the type you want it to be deserialized.
That is, the last tuple element serves as a marker for the deserialization type (in the same way `PK` does it in
`UniqueIndex`).

- There are currently some inconsistencies in the values that are returned for the different index keys. `MultiIndex`
returns a tuple with the remaining part of the index key along with the primary key, whereas `UniqueIndex` returns only
the primary key. This will be changed in the future (See https://github.com/CosmWasm/cw-plus/issues/532) for consistency
and compatibility with the base `Map` type behaviour.
Loading

0 comments on commit bdc9965

Please sign in to comment.