Skip to content

Commit 31818c3

Browse files
author
Mauro Lacy
committed
Update MIGRATING guide
1 parent 8c677ce commit 31818c3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

MIGRATING.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@
22

33
This guide lists API changes between *cw-plus* major releases.
44

5+
## v0.13.x -> v0.14.0
6+
7+
### Breaking Issues / PRs
8+
9+
- `MultiIndex` index fn params now include the pk [\#670](https://github.com/CosmWasm/cw-plus/issues/670)
10+
11+
The `idx_fn` param of the `MultiIndex` constructor now has signature `fn(&[u8], &T) -> IK`, where the first param is the
12+
primary key of the index (in raw format), and the second param is the associated value.
13+
That allows us to use the pk or parts of it for building the index key.
14+
15+
Migration of existing code is straight-forward. Just add an (unused) `_pk` param to the index function definition:
16+
17+
```diff
18+
fn build_map<'a>() -> IndexedMap<'a, &'a str, Data, DataIndexes<'a>> {
19+
let indexes = DataIndexes {
20+
- name: MultiIndex::new(|d| d.name.clone(), "data", "data__name"),
21+
+ name: MultiIndex::new(|_pk, d| d.name.clone(), "data", "data__name"),
22+
age: UniqueIndex::new(|d| d.age, "data__age"),
23+
name_lastname: UniqueIndex::new(
24+
```
25+
26+
If you want to leverage this new functionality, take a look at the `pk_based_index()` test / example
27+
in `src/indexed_map.rs`.
28+
529
## v0.11.0 -> v0.12.0
630

731
### Breaking Issues / PRs

0 commit comments

Comments
 (0)