Save, delete, or update a user scoped document in NerdStorage.
Usage
import { UserStorageMutation } from 'nr1'
Examples
Write document
UserStorageMutation.mutate({ actionType: UserStorageMutation.ACTION_TYPE.WRITE_DOCUMENT, collection: 'myCollection', documentId: 'myDocumentId', document: { name: 'John', surname: 'Doe', },});
Delete document
UserStorageMutation.mutate({ actionType: UserStorageMutation.ACTION_TYPE.DELETE_DOCUMENT, collection: 'myCollection', documentId: 'myDocumentId',});
Delete collection
UserStorageMutation.mutate({ actionType: UserStorageMutation.ACTION_TYPE.DELETE_COLLECTION, collection: 'myCollection',});
Props
REQUIREDenum | Type of action to perform. <One of |
REQUIREDfunction | Render prop function as children. function ( |
string | Collection name. |
object | NerdStorage document. Documents are restricted to 64 kB in size when JSON-stringified. |
string | 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.
}