store

handle storing data persistently store "DynamoDB"

How to use

import { Plugin } from '@root'

Plugin.store({
    ...STORE_PAYLOAD
})

Store payload

Save data to store

import { Plugin } from '@root'

const item = {
    id: 'item-id',
    name: 'item name'
}

const onSave = () => {

}

Plugin.store({
    key: 'my-store-key',
    data: item,
    method: 'POST',
    callback: onSave
})

Get data from store

import { Plugin } from '@root'

const onGet = storedData => {
    console.log(storedData)
    /*
        Output:
        {
            id: 'item-id',
            name: 'item name'
        }
    */
}

Plugin.store({
    key: 'my-store-key',
    method: 'GET', // can be ignored, as GET is the default method for cache
    callback: onGet
})

Remove data from store

import { Plugin } from '@root'

Plugin.store({
    key: 'my-store-key',
    method: 'DELETE'
})

Last updated