Skip to main content
added 14 characters in body
Source Link
kianenigma
  • 2.9k
  • 5
  • 17

How do I mutate a DoubleStorageMapDoubleStorageMap with a Vec<T::AccountId>Vec<T::AccountId> as a value using a struct?

Data::<T>::mutate(
  id.clone(),
  user_id.clone(),
  |params: &mut DataParams<T::AccountId>| {
    params.users.push(new_user);
    params.total_users += 1;
  }
);
Data::<T>::mutate(
  id.clone(),
  user_id.clone(),
  |params: &mut DataParams<T::AccountId>| {
    params.users.push(new_user);
    params.total_users += 1;
  }
);

total_users doesn't increase but users only ever has one user.


What's the best way to accomplish this? The mutate is within a for loop and needs to append multiple users.

How do I mutate a DoubleStorageMap with a Vec<T::AccountId> as a value using a struct?

Data::<T>::mutate(
  id.clone(),
  user_id.clone(),
  |params: &mut DataParams<T::AccountId>| {
    params.users.push(new_user);
    params.total_users += 1;
  }
);

total_users doesn't increase but users only ever has one user.


What's the best way to accomplish this? The mutate is within a for loop and needs to append multiple users.

How do I mutate a DoubleStorageMap with a Vec<T::AccountId> as a value using a struct?

Data::<T>::mutate(
  id.clone(),
  user_id.clone(),
  |params: &mut DataParams<T::AccountId>| {
    params.users.push(new_user);
    params.total_users += 1;
  }
);

total_users doesn't increase but users only ever has one user.


What's the best way to accomplish this? The mutate is within a for loop and needs to append multiple users.

added 7 characters in body
Source Link

How do I mutate a DoubleStorageMap with a Vec<T::AccountId> as a value using a struct?

Data::<T>::mutate(
  id.clone(),
  user_id.clone(),
  |params: &mut DataParams<T::AccountId>| {
    params.users.push(new_user);
    params.total_users += 1;
  }
);

total_users increasesdoesn't increase but users only ever has one user.


What's the best way to accomplish this? The mutate is within a for loop and needs to append multiple users.

How do I mutate a DoubleStorageMap with a Vec<T::AccountId> as a value using a struct?

Data::<T>::mutate(
  id.clone(),
  user_id.clone(),
  |params: &mut DataParams<T::AccountId>| {
    params.users.push(new_user);
    params.total_users += 1;
  }
);

total_users increases but users only ever has one user.


What's the best way to accomplish this? The mutate is within a for loop and needs to append multiple users.

How do I mutate a DoubleStorageMap with a Vec<T::AccountId> as a value using a struct?

Data::<T>::mutate(
  id.clone(),
  user_id.clone(),
  |params: &mut DataParams<T::AccountId>| {
    params.users.push(new_user);
    params.total_users += 1;
  }
);

total_users doesn't increase but users only ever has one user.


What's the best way to accomplish this? The mutate is within a for loop and needs to append multiple users.

Source Link

How to mutate a Vec<u16> in a struct in a DoubleStorageMap?

How do I mutate a DoubleStorageMap with a Vec<T::AccountId> as a value using a struct?

Data::<T>::mutate(
  id.clone(),
  user_id.clone(),
  |params: &mut DataParams<T::AccountId>| {
    params.users.push(new_user);
    params.total_users += 1;
  }
);

total_users increases but users only ever has one user.


What's the best way to accomplish this? The mutate is within a for loop and needs to append multiple users.