Currently the only available setter Store.set()
either sets a single item or takes an object to set multiple values. Providing an object would overwrite the whole value, which is a normal/expected behavior. Though, this leaves out use cases where we want to update multiple fields at a path in one go.
Example:
const store = new Store();
store.store = {
users: {
p9dsbfo0b0sbd: {
name: 'John Smith',
email: '[email protected]',
age: 52,
occupation: {
title: 'Web Developer',
remote: false
}
}
}
};
// Updating multiple values (we'll either lose 'email' and 'occupation.title' fields or a schema validation error is thrown)
store.set('users.p9dsbfo0b0sbd', {
name: 'John M. Smith',
age: 53,
occupation: {
remote: true
}
});
// Must do
store.set('users.p9dsbfo0b0sbd.name', 'John M. Smith');
store.set('users.p9dsbfo0b0sbd.age', 53);
store.set('users.p9dsbfo0b0sbd.occupation.remote', true);
// Better be able to do (object should be merged deeply)
store.update('users.p9dsbfo0b0sbd', {
name: 'John M. Smith',
age: 53,
occupation: {
remote: true
}
});
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too