• /
  • Log in
  • Free account

UserStorageMutation

Save, delete, or update a user scoped document in NerdStorage.

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: {Object //

Results of the mutation.

) => undefined
collectionstring

Name of the collection to mutate.

documentobject

NerdStorage document.

Documents are restricted to 64KB in size.

documentIdstring

ID of the document to mutate.

Methods

UserStorageMutation.render

function () => undefined

UserStorageMutation.mutate

Static method to use UserStorageMutation as a Promise instead of as a React component.

function (
props: Object //

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

) => {Object}

Type definitions

PromiseQueryResult

{
loading: boolean, //

Indicates that the request is in flight.

data: Object, //

An object containing the result of your query.

}
Create issueEdit page
Copyright © 2021 New Relic Inc.