Storing and retrieving data with StoreClient is very simple.
There is no need to require it - it comes pre-imported in your Code environment.
You will need to provide a secret that will protect your data. I recommend using Random.org's excellent password generator. Be very sure you pick a complex secret - if anyone guesses it they'll be able to read and write your data!
Instantiating a client is very simple:
var store = StoreClient('your secret here');
StoreClientis a promise based library and a great time to get familiar withasyncandawait!
Most likely you just want to get and set some values - this is the simplest possible example:
const store = StoreClient('your secret here');
await store.set('hello', 'world');
const value = await store.get('hello');
return {result: value} // value === 'world'If the value doesn't exist during your get() call - it will return a null value.
Bulk Operations
You can also save and retrieve multiple keys and values - a slightly more complex example:
const store = StoreClient('your secret here');
await store.setMany({hello: 'world', foo: 'bar'})
const values = await store.getMany('hello', 'foo');
// values === {hello: 'world', foo: 'bar'}
await store.deleteMany('hello', 'foo');
// or, if you want to wipe everything
await store.clear();Note, you can call getMany and deleteMany in a few different ways:
store.getMany('hello', 'foo'); // as arguments
store.getMany(['hello', 'foo']); // as array
store.getMany({hello: null, foo: null}); // as objectAPI
You can also access the stored data via our store API. More info at https://store.zapier.com/
Limitations
- Any JSON serializable value can be saved.
- The secret must be under 32 chars in length.
- Every key must be under 32 chars in length.
- Every value must be under 250 kb.
- Only 500 keys may be saved per secret.
- Keys will expire if you do not touch them in 3 months.