I have this:
struct MyEntity {
val name: String,
val age: u64
}
Then I do this in js tests:
let {addr1: Ok} = await alice.call("my_app", "create_my_entity", { ....});
//1
let res1 = await alice.call("my_app", "update_my_entity", {addr: addr1, age: 33});
let {addr2: Ok} = res1;
//2
let res2 = await alice.call("my_app", "update_my_entity", {addr: addr2, age: 23});
let {addr3: Ok} = res2;
//3
let res3 = await alice.call("my_app", "update_my_entity", {addr: addr3, age: 11});
Now this
let myEntities = await alice.call("my_app", "get_all_entities", { });
will return a vector of identical MyEntity the same amount of times Iāve updated it - 3 times + 1 instance for creation. Except ā the Addresses will be different.
If I had, say, 5 different MyEntity and updated them several times, the function would return (5*times_each_one_was_updated). This isnāt what Iād need, Iād need only 5.
"get_all_entities" is implemented as `hdk::query("my_entity".into(), 0, 0)`
Q: How can I get it to return only the latest instance/version of each MyEntity?
In other words, after I update an Entity, it returns a new address and a new, updated record gets created, right? How can I retrieve only the updated, latest record of each individual Entity?