@varasto/multi-storage

Combines multiple Varasto storages into one

Usage no npm install needed!

<script type="module">
  import varastoMultiStorage from 'https://cdn.skypack.dev/@varasto/multi-storage';
</script>

README

@varasto/multi-storage

Storage implementation which retrieves and stores data to multiple other storage instances.

Installation

$ npm install --save @varasto/multi-storage

Usage

The package provides an function called createMultiStorage which takes multiple other storage instances as arguments. Data is retrieved from and stored to storages given as arguments.

import { createMemoryStorage } from '@varasto/memory-storage';
import { createMultiStorage } from '@varasto/multi-storage';

const storage1 = createMemoryStorage();
const storage2 = createMemoryStorage();

const multiStorage = createMultiStorage(storage1, storage2);

// This will insert the entry to both `storage1` and `storage2`.
await multiStorage.set('foo', 'bar', { value: 5 });