# botkit-promise-storage

> Creates a promise-based storage interface for botkit

Latest version **1.1.0** (published 2016-03-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install botkit-promise-storage
pnpm add botkit-promise-storage
yarn add botkit-promise-storage
bun add botkit-promise-storage
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2016-03-18 |
| First published | 2016-03-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Cole Furfaro-Strode |
| Maintainers | cfs |
| Keywords | botkit, promise, storage |

## Links

- npm: https://www.npmjs.com/package/botkit-promise-storage
- Repository: https://github.com/colestrode/botkit-promise-storage
- Homepage: https://github.com/colestrode/botkit-promise-storage#readme
- Issues: https://github.com/colestrode/botkit-promise-storage/issues
- npm.io page: https://npm.io/package/botkit-promise-storage

## Dependencies (2)

- [q](https://npm.io/package/q.md) ^1.4.1
- [lodash](https://npm.io/package/lodash.md) ^4.6.1

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2016-03-18
- 1.0.0 — 2016-03-09

## README

# botkit-promise-storage
[![Build Status](https://travis-ci.org/colestrode/botkit-promise-storage.svg?branch=master)](https://travis-ci.org/colestrode/botkit-promise-storage)
[![Coverage Status](https://coveralls.io/repos/github/colestrode/botkit-promise-storage/badge.svg?branch=master)](https://coveralls.io/github/colestrode/botkit-promise-storage?branch=master)

Returns a promise-based storage interface for botkit.

## Usage

```js
var controller = require('botkit').slackbot();
var promiseStorage = require('botkit-promise-storage')(controller);

promiseStorage.teams.get('teamId')
  .then(function(team) {
    console.log(team);
  })
  .fail(function(err) {
    console.log(err);
  });
```

This doesn't overwrite the storage interface for botkit but instead provides a new one interface you can use. Botkit 
relies on its own callback-based storage interface internally, so do not overwrite the existing storage module.

## Interface

The returned storage object has the same interface as `controller.storage` with the addition of a `merge` method.
Each method returns a promise. The following methods are exported for each scope (`teams`, `channels`, `users`):

### all

Retrieves all data for this scope.

### get

Takes an ID and will return either the data stored with that ID or `undefined`.

### merge

A convenience method not found in the botkit storage modules. Takes an object with an `id` property and will merge it with
any existing data with that ID. If there is no existing data with the given ID, this will function as a `save`. 

Generally, `merge` should be preferred over `save`.

### save

Takes an object with an `id` property and saves it. This will overwrite whatever data is previously stored with this ID.


## Notes

This uses the promises A+ compliant [q](https://github.com/kriskowal/q) library for promises.

---
_Source: https://npm.io/package/botkit-promise-storage · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
