Updating
Use store.update()
and store.remove()
to update groups. The following operations are possible:
Using update()
:
replace the contents of a group
append new items to the end of a group
Using remove()
:
remove resource(s) from a group
Heads up: you can also delete an entire group using either
update()
orremove()
. This is covered in the next guide, Deleting Groups.
Replacing a Group
Replacing the contents of a group is straightforward: it looks the exact same as the call to create a group. In this example, we replace our selectedBooks
group with a different set of IDs:
Appending to a Group
Sometimes, you want to add a new value to a group without losing the old values. Once again, you use store.update()
for this purpose. One of the options to store.update()
is called concatGroups
. Pass it as true
, and the IDs will be added to the group.
Removing Resources From a Group
To remove resources from a group, you can use store.remove()
. The arguments are the same as adding a resource to the group.
Updating Multiple Groups
The previous examples used the path
argument to store.update()
to update a single group. But you can update as many groups across as many resources at a single time using these methods. In this example, we perform a bulk operation to replace several groups at the same time:
Tips
Resources that don't exist at the time that you add them to a group will be created for you. This is
useful if you need to create a resource and add it to a group at the same time.
Last updated