All Projects → jrop → nedb-promise

jrop / nedb-promise

Licence: other
Promisified nedb wrapper

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to nedb-promise

doasync
Promisify functions and objects immutably
Stars: ✭ 27 (-71.58%)
Mutual labels:  promise-wrapper, promise
promiviz
Visualize JavaScript Promises on the browser. Visualize the JavaScript Promise APIs and learn. It is a playground to learn about promises faster, ever!
Stars: ✭ 79 (-16.84%)
Mutual labels:  promise, promise-api
QDeferred
Qt C++ alternative for handling async code execution
Stars: ✭ 62 (-34.74%)
Mutual labels:  promise, promise-api
Escape From Callback Mountain
Example Project & Guide for mastering Promises in Node/JavaScript. Feat. proposed 'Functional River' pattern
Stars: ✭ 249 (+162.11%)
Mutual labels:  promise
Axios
Promise based HTTP client for the browser and node.js
Stars: ✭ 89,857 (+94486.32%)
Mutual labels:  promise
When
⏰ A lightweight implementation of Promises in Swift
Stars: ✭ 250 (+163.16%)
Mutual labels:  promise
vue-geolocation
ask to your users their coordinates, and wrap them into a Promise
Stars: ✭ 88 (-7.37%)
Mutual labels:  promise
Spirit
Modern modular library for building web applications
Stars: ✭ 241 (+153.68%)
Mutual labels:  promise
market-pricing
Wrapper for the unofficial Steam Market Pricing API
Stars: ✭ 21 (-77.89%)
Mutual labels:  promise
promise-all-properties
A helper function that recevies an object with a promise in each property and returns a promise that resolves to an object with the same properties and the resolved values of the promises
Stars: ✭ 26 (-72.63%)
Mutual labels:  promise
promise4j
Fluent promise framework for Java
Stars: ✭ 20 (-78.95%)
Mutual labels:  promise
promise-waterfall
promise-waterfall extends promise utilities with sequential flow control function like async.waterfall
Stars: ✭ 28 (-70.53%)
Mutual labels:  promise
vue-nuxt-passport-bulma-express-boiler
A Vue+Vuex starter with Nuxt scaffolding, Bulma styling, and Express backend.
Stars: ✭ 21 (-77.89%)
Mutual labels:  nedb
bluff
🙏 Promise A+ implementation
Stars: ✭ 14 (-85.26%)
Mutual labels:  promise
alls
Just another library with the sole purpose of waiting till all promises to complete. Nothing more, Nothing less.
Stars: ✭ 13 (-86.32%)
Mutual labels:  promise
Task Easy
A simple, customizable, and lightweight priority queue for promises.
Stars: ✭ 244 (+156.84%)
Mutual labels:  promise
fetchye
✨ If you know how to use Fetch, you know how to use Fetchye [fetch-yae]. Simple React Hooks, Centralized Cache, Infinitely Extensible.
Stars: ✭ 36 (-62.11%)
Mutual labels:  promise
promised-hooks
Middleware utility for your Promises
Stars: ✭ 25 (-73.68%)
Mutual labels:  promise
unity-promises
Promises provide a simpler alternative for executing, composing, and managing asynchronous operations when compared to traditional callback-based approaches. They also allow you to handle asynchronous errors using approaches that are similar to synchronous try/catch.
Stars: ✭ 36 (-62.11%)
Mutual labels:  promise
promise-yes
Slide about how to use Promise in JavaScript.
Stars: ✭ 13 (-86.32%)
Mutual labels:  promise

nedb-promise

A promise wrapper for 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 [email protected] 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].