# nedb-promise

> A promise wrapper around the nedb package

Latest version **2.0.1** (published 2017-01-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install nedb-promise
pnpm add nedb-promise
yarn add nedb-promise
bun add nedb-promise
```

## 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 | 2.0.1 |
| Published | 2017-01-24 |
| First published | 2015-08-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 96 |
| Author | Jonathan Apodaca |
| Maintainers | jrop |
| Keywords | nedb, promise |

## Links

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

## Dependencies (2)

- [nedb](https://npm.io/package/nedb.md) ^1.8.0
- [thenify](https://npm.io/package/thenify.md) ^3.2.0

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 2.0.1 (latest) — 2017-01-24
- 2.0.0 — 2016-03-08
- 1.0.4 — 2016-03-08
- 1.0.3 — 2016-02-29
- 1.0.2 — 2016-02-28
- 1.0.1 — 2015-09-25
- 1.0.0 — 2015-08-14
- 0.1.1 — 2015-08-14
- 0.1.0 — 2015-08-14

## README

nedb-promise
============

A promise wrapper for [NeDB](https://github.com/louischatriot/nedb).

Installation
============

Install with NPM:

`$ npm i --save nedb-promise`

Usage
=====

Example using ES7 async/await:
```
import datastore from 'nedb-promise'

async function doDatabaseStuff() {
  let DB = datastore({
     // these options are passed through to nedb.Datastore

     filename: 'my-db.json',

     autoload: true // so that we don't have to call loadDatabase()
  })

  await DB.insert([{
    num: 1, alpha: 'a'
  }, {
    num: 2, alpha: 'b'
  }])

  let document = await DB.findOne({ num: 1 })

  // use NeDB cursors:
  let documents = await DB.cfind({})
    .projection({ num: 1, _id: 0 })
    .exec()
}

doDatabaseStuff()
```

API
===

## datastore(options)

Returns an object that proxies to an internal `nedb.Datastore` instance (`options` are passed through to the NeDB constructor), with promisified methods.

It also includes extension methods `cfind(...)`, `cfindOne(...)`, and `ccount(...)` that return promisified cursors, so that you may do:

```
let results = await myDataStore.cfind({ moo: 'goo' })
  .projection({ moo: 1, _id: 0 }) // see NeDB cursor methods
  .exec()
```

## datastore.fromInstance(nedbInstance)

Use this method if you already have a NeDB instance that you want to wrap with the promisified methods.

Testing
=======

Run tests with mocha (after building):

```
$ mocha test.js
```

License
=======
Copyright (c) 2015, Jonathan Apodaca <jrapodaca@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

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