@wranggle/storage-node
Version:
WranggleStorage bundle that includes the main feature layers and persistence adapters for a Node environment
48 lines (29 loc) • 1.71 kB
Markdown
# @wranggle/storage-node
This *@wranggle/storage-node* package bundles the main feature layers and persistence adapters used in an Electron or Node environment.
This page is dedicated to installation/setup. See the main [WranggleStorage](https://github.com/wranggle/storage) documentation for additional instructions.
## Setup
### Installation
1. Add the [@wranggle/storage-node](https://www.npmjs.com/package/@wranggle/storage-node) package to your project:
```bash
# From the command line using yarn:
yarn add @wranggle/storage-node
# or with npm:
npm install @wranggle/storage-node
```
1. In your JavaScript, import or require WranggleStorage:
```javascript
import { WranggleStorage } from '@wranggle/storage-node';
// or:
const { WranggleStorage } = require('@wranggle/storage-node');
```
Alternatively, you can install and use just the persistence adapter and feature layers needed. (See individual package instructions.)
### Create your store
Make sure your persistence library is available.
To use the [sindresorhus/conf](https://github.com/sindresorhus/conf) library for persistence, saving data in a json file, you can use the `conf` shortcut to specify you want the *ConfigFileAdapter* adapter. Eg:
```javascript
const conf = new Conf(myConfOpts);
const store = new WranggleStorage({ conf });
```
See the [ConfigFileAdapter instructions](https://github.com/wranggle/storage/tree/master/packages/storage-config-file-adapter) for its configuration options.
## Next Steps
Next, you'll want to add some feature layers. See the main [WranggleStorage](https://github.com/wranggle/storage#Feature-Layers) documentation for instructions.