You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@sean-nicholas/nedb-database

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sean-nicholas/nedb-database

Simple typescript & class support for NeDB

1.0.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

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.

FAQs

Package last updated on 08 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts