@sean-nicholas/nedb-database
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

NeDB Database

A simple wrapper for some of the nedb functionality. It puts nedb into a class and adds typescript types.

Usage

Create a new database via:

const db = new Database<YourEntityType>({
  filename: 'path/to/nedb-file'
})

Initialization

To init your db just provide an array with a query and the corresponding value that should be added to the database. The init function checks if the value exists in the db and creates it otherwise.

await db.init([
  {
    query: { key: 'myConfig' },
    value: {
      key: { key: 'myConfig' },
      value: 'here it is'
    }
  }
])

Querying, Inserting & Co.

It is basically the same syntax as nedb but with promises:

const entry = await db.findOne({ key: 'myConfig' })

await db.update({ key: 'myConfig' }, {
    key: 'myConfig'
    value: 'new value'
  })

Supported methods are: insert, find, fineOne, count, update, remove. Cursor operations are not supported.

Readme

Keywords

none

Package Sidebar

Install

npm i @sean-nicholas/nedb-database

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

13.8 kB

Total Files

9

Last publish

Collaborators

  • sean-nicholas