-
-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add update method [Feature Request] #240
Comments
Seems useful to me. Is it expected to a user that it does deep merging though? |
@sindresorhus I think deep merging is more practical, but users might expect a shallow merge based on other database operators such as MongoDB. We can however provide both methods through either: // Additional argument
update(key: string, object: any, deepMerge: boolean = false)
// Example
store.update('users.p9dsbfo0b0sbd', {
name: 'John M. Smith',
age: 53,
occupation: {
remote: true
}
}, true); or a different method altogether: // Shallow merge
update(key: string, object: any)
// Deep merge
merge(key: string, object: any) Though I personally prefer the first approach. If you find this useful, once we agree on an approach, I can create a dependency-free PR for |
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:
The text was updated successfully, but these errors were encountered: