# storage-scout

> File system storage API

Latest version **0.2.1** (published 2016-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install storage-scout
pnpm add storage-scout
yarn add storage-scout
bun add storage-scout
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2016-11-07 |
| First published | 2016-10-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | David Goodwin |
| Maintainers | goodwid |
| Keywords | database, file |

## Links

- npm: https://www.npmjs.com/package/storage-scout
- npm.io page: https://npm.io/package/storage-scout

## Dependencies (1)

- [sander](https://npm.io/package/sander.md) ^0.5.1

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 0.2.1 (latest) — 2016-11-07
- 0.2.0 — 2016-11-02
- 0.1.1 — 2016-10-31
- 0.1.0 — 2016-10-31

## README

# storage-scout

This is (yet another) JSON-centric file-system-based storage API, using [sander](https://www.npmjs.com/package/sander) to store data in a folder in `.json` files, one file per data point.

### API

There are five methods exposed:

##### storageScout.create
*  Requires one parameter, a JSON string containing a data element.   
*  Returns a promise, with the data object with an ID added.

``` js
const data = '{"Name":"Dune", "Author":"Frank Herbert"}';

storageScout.create(data)
  .then (result => console.log(result)) // '{"Name":"Dune", "Author":"Frank Herbert", "id": "1"}'
  .catch (err => console.error(error));
```

##### storageScout.readAll
*  Requires zero parameters.  
*  Returns a promise, with a JSON string with all data elements in an array.

``` js
storageScount.readAll()
  .then(results => console.log(results)) // '[{"Name":"Dune", "Author":"Frank Herbert", "id": "1"}]'
  .catch(err => console.error(err));
```

##### storageScout.readOne
*  Requires one parameter, an ID as a string.  
*  Returns a promise, with a JSON string with the data element requested.

``` js
storageScount.readAll('1')
  .then(result => console.log(result)) //  '{"Name":"Dune", "Author":"Frank Herbert", "id": "1"}'
  .catch(err => console.error(err));
```

##### storageScout.update
*  Requires two parameters, first, an ID as a string, second, a JSON string containing new data.  
*  Returns a promise, with the new data set.

``` js
const newData = '{"Name":"Dune Messiah", "Author":"Frank Herbert"}';
storageScout.update('1', newData)
  .then(result => console.log(result)) // '{"Name":"Dune Messiah", "Author":"Frank Herbert", "id": "1"}'
  .catch(err => console.error(err));
```

##### storageScout.delete
*  Requires one parameter, an ID as a string.  
*  Returns a promise, a message confirming deletion of the ID

``` js
storageScout.delete('1')
  .then(result => console.log(result)) // '{"message":"1 deleted"}'
  .catch(err => console.error(err));
```


These are standard CRUD operations on data.  Appropriate errors are returned if operations fail or if data provided is not valid JSON.

Thanks to [Caitlin Araldi](https://github.com/caraldi) and [Dave Hanagan](https://github.com/billyham) for identifying a bug that causes the filestore to break when files such as .DS_store are present.

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