---
title: EntityStorageMutation
source: https://docs.newrelic.com/docs/new-relic-solutions/build-nr-ui/sdk-component/query-and-storage/EntityStorageMutation
---

Save, delete, or update an entity scoped document in NerdStorage. In order to successfully perform this operation, the user must have the right permissions.

### Usage

```js
import { EntityStorageMutation } from 'nr1'
```

### Examples

#### Write document

```js
EntityStorageMutation.mutate({
  entityGuid: 'MTIzNDU2fEZPT3xCQVJ8OTg3NjU0Mzcz',
  actionType: EntityStorageMutation.ACTION_TYPE.WRITE_DOCUMENT,
  collection: 'myCollection',
  documentId: 'myDocumentId',
  document: {
    name: 'John',
    surname: 'Doe',
  },
});
```

#### Delete document

```js
EntityStorageMutation.mutate({
  entityGuid: 'MTIzNDU2fEZPT3xCQVJ8OTg3NjU0Mzcz',
  actionType: EntityStorageMutation.ACTION_TYPE.DELETE_DOCUMENT,
  collection: 'myCollection',
  documentId: 'myDocumentId',
});
```

#### Delete collection

```js
EntityStorageMutation.mutate({
  entityGuid: 'MTIzNDU2fEZPT3xCQVJ8OTg3NjU0Mzcz',
  actionType: EntityStorageMutation.ACTION_TYPE.DELETE_COLLECTION,
  collection: 'myCollection',
});
```

### Props

| `actionType` REQUIREDenum   | Type of action to perform. EntityStorageMutation.ACTION_TYPE.DELETE_COLLECTION, EntityStorageMutation.ACTION_TYPE.DELETE_DOCUMENT, EntityStorageMutation.ACTION_TYPE.WRITE_DOCUMENT,                                                                                                                                              |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `children` REQUIREDfunction | Render prop function as children.                                                                                                                                                                                                                                                                                                 |
| `collection` REQUIREDstring | Collection name.                                                                                                                                                                                                                                                                                                                  |
| `document` object           | NerdStorage document. Documents are restricted to 64 kB in size when JSON-stringified.                                                                                                                                                                                                                                            |
| `documentId` string         | Document identifier to operate in. When omitted the whole collection is returned.                                                                                                                                                                                                                                                 |
| `entityGuid` REQUIREDstring | GUID of the entity in which the collection is operated.                                                                                                                                                                                                                                                                           |
| `scopeByActor` boolean      | Establishes whether the data needs to be scoped by actor or not; that is, whether the data read or saved is common to everybody having access to the object, or it is exclusive of the user.An object (entity or account) can have both "global" data and "scoped" data, and the data read will depend on the status of the flag. |

### Methods

### `EntityStorageMutation.mutate`

### Type definitions
