Here is the code on how to grab from and array:
struct Collection {
uint collectionId;
uint collectionType;
address collectionOwnerAddress;
uint value;
}
Collection[] public collections;
function getCollection (uint _collectionId) view public returns (uint) {
return collections[_collectionId].value;
}
My question is: I'm curious if I can grab the collection by the collection owners address. Something like this? Can I select by both msg.sender and collectionType?
function getCollection (uint _collectionType) view public returns (uint) {
// select by _collectionType and msg.sender here
return collections[msg.sender].value;
}
I'm trying to incrementally increase the value. So during addCollection if the array doesn't exist with that member then it creates a new array.push row. But, if the user already has an index in the array it collections[_collectionId].value++ instead of adding another array index row for that user. This above question relates because I cant loop through the whole collections array to see if that member already started a collection.