Promise wrapper for Nedb that makes it possible to use all Nedb all cursor modifiers.
npm install nedb-async**nedb-async is a simply promise base wrapper methods for
Nedb**
bash
npm install nedb-async
`
or with yarn
`bash
yarn add nedb-async
`Usage
It is very simple and to avoid too much complexity all the cursor modifiers for
find, findOne and count
methods have to be passed as the last argument in an array.---
Very important to know that all the promise base methods starts with async then the method name in camel casing
-
asyncFind
- asyncFindOne
- asyncCount
- asyncInsert
- asyncUpdate
- asyncRemove
- asyncEnsureIndex
- asyncRemoveIndexand every other ned
b origin methods are still available.``js
db.asyncFind({}, [['sort', { name: -1 }], ['limit', 2]])
.then(function(docs) {})
.catch(function(error) {})
//Or with async await
async function getUsers() {
let users = await db.asyncFind({}, [['limit', 100]])
}
async function countAllUsers() {
let users = await db.asyncCount({})
}
`
For Nodejs
`js
const { AsyncNedb } = require('nedb-async')
const data = new AsyncNedb({
filename: 'data.db',
autoload: true,
})
`
For typescript users consider using this approach for better types support
`ts
import AsyncNedb from 'nedb-async'
interface IUser {
firstName: string
lastName: string
age: number
email: string
}
const User = new Nedb
`
Please use the official Nedb documentation for more information.
Build the package - outputs built files to ./dist/. These are the ones that will ultimately end up in the pacakage.`bash`
npm run-script build`
orbash`
yarn build`
Linter - runs standard lint checks to keep code clean.bash`
npm run-script lint`
orbash`
yarn lint`
Formatter - formats the code in place for consistency.bash`
npm run-script format`
orbash``
yarn format
MIT