On August 31, 2024, we're EOLing developer.newrelic.com. All relevant content has been migrated to docs.newrelic.com.

UserStorageMutation

Usage

import { UserStorageMutation } from 'nr1'

Examples

Write document

1
UserStorageMutation.mutate({
2
actionType: UserStorageMutation.ACTION_TYPE.WRITE_DOCUMENT,
3
collection: 'myCollection',
4
documentId: 'myDocumentId',
5
document: {
6
name: 'John',
7
surname: 'Doe',
8
},
9
});

Delete document

1
UserStorageMutation.mutate({
2
actionType: UserStorageMutation.ACTION_TYPE.DELETE_DOCUMENT,
3
collection: 'myCollection',
4
documentId: 'myDocumentId',
5
});

Delete collection

1
UserStorageMutation.mutate({
2
actionType: UserStorageMutation.ACTION_TYPE.DELETE_COLLECTION,
3
collection: 'myCollection',
4
});

Props

actionTyperequiredenum

Type of action to perform.

<One of
UserStorageMutation.ACTION_TYPE.DELETE_COLLECTION,
UserStorageMutation.ACTION_TYPE.DELETE_DOCUMENT,
UserStorageMutation.ACTION_TYPE.WRITE_DOCUMENT,
>
childrenrequiredfunction

Render prop function as children.

function (
mutate: function,

Function to trigger a mutation from your UI.

mutationResult: MutationResult

Results of the mutation.

) => React.ReactNode
collectionstring

Collection name.

documentobject

NerdStorage document. Documents are restricted to 64 kB in size when JSON-stringified.

documentIdstring

Document identifier to operate in. When omitted the whole collection is returned.

Methods

UserStorageMutation.mutate

function (
props: Object

Object containing the mutation options. Any UserStorageMutation prop is a valid option except children.

) => PromiseQueryResult

Type definitions

PromiseQueryResult

{
error: ApolloClient.ApolloError,

Runtime error with graphQLErrors and networkError properties.

data: Object,

Object containing the result of your query.

fetchMore: function|null,

If not null, fetchMore allows you to load more results for your query. New data is merged with previous data.

refetch: function,

Refetch the query.

}

MutationResult

{
loading: boolean,

Indicates that the request is in flight.

error: ApolloClient.ApolloError,

Runtime error with graphQLErrors and networkError properties.

data: Object,

Object containing the result of your mutation.

}