• /
  • EnglishEspañol日本語한국어Português
  • Log inStart now

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

import { EntityStorageMutation } from 'nr1'

Examples

Write document

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

Delete document

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

Delete collection

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

Props

actionType

REQUIRED
enum

Type of action to perform.

<One of

EntityStorageMutation.ACTION_TYPE.DELETE_COLLECTION, EntityStorageMutation.ACTION_TYPE.DELETE_DOCUMENT, EntityStorageMutation.ACTION_TYPE.WRITE_DOCUMENT,

>

children

REQUIRED
function

Render prop function as children.

function (
mutate: function,

Function to trigger a mutation from your UI.

mutationResult: MutationResult

Results of the mutation.

) => React.ReactNode

collection

REQUIRED
string

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

REQUIRED
string

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

function (
props: Object

Object containing the mutation options. Any EntityStorageMutation 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.

}
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.