unstorage
unstorage copied to clipboard
How to perform mutations inside a store
Something like
store.patch({
count: store.count + 1,
age: 120,
name: 'DIO',
})
OR
store.patch((state) => {
state.items.push({ name: 'shoes', quantity: 1 })
state.hasChanged = true
})
Sorry, just found it in the docs. Even possible with setItem I see. That's cool🚀
Not sure yet how to push to an array yet.
Something like this
store.patch((state) => {
state.items.push({ name: 'shoes', quantity: 1 })
state.hasChanged = true
})
Is that also possible?
Any thoughts?
unstorage is a KV database you need one getItem + one setItem