Standard Resource
  • Introduction
  • Read Me
  • Introduction
    • Motivation
    • Core Concepts
  • Store
    • Creating a Store
  • Resources
    • Resource Data
    • Creating
    • Retrieving
    • Updating
    • Deleting
    • Using Computed Attributes
    • Schemas
  • Groups
    • Creating
    • Retrieving
    • Updating
    • Deleting
    • Sorted Groups
  • API Reference
    • createResourceStore
    • Store
  • Glossary
  • Changelog
Powered by GitBook
On this page
  • Deleting a Single Group
  • Deleting Multiple Groups at Once
  • Using update() to Delete a Group
  1. Groups

Deleting

PreviousUpdatingNextSorted Groups

Last updated 7 years ago

Use to delete groups.

Deleting a Single Group

In this example, we delete the group with the name "selectedBooks".

store.remove('groups.selectedBooks');

Deleting Multiple Groups at Once

You can delete multiple groups by passing an array of group names to delete when calling remove().

store.remove('groups', ['selectedBooks', 'newBooks', 'favoriteMovies']);

Here are two other ways to accomplish the same thing:

store.remove({
  groups: ['selectedBooks', 'newBooks', 'favoriteMovies'],
});

store.remove({
  groups: {
    selectedBooks: null,
    newBooks: null,
    favoriteMovies: null,
  },
});

Using update() to Delete a Group

store.update('groups.selectedBooks', []);
store.update('groups.selectedBooks', null);

You may choose to use one over the other when it makes sense as part of a bulk operation.

For instance, in the following call to store.update(), we are able to update a resource and delete a group at the same time:

store.update({
  resources: {
    24: {
      attributes: {
        firstName: 'James',
      },
    },
  },
  groups: {
    selectedBooks: [],
  },
});

Had we used remove() to delete this list, we would have had to create the resource in a separate call to update(), which is why in this situation it made more sense to use update to delete the list.

Passing null or an empty array to will delete the group.

store.remove()
store.update()