flash-store

FlashStore v0.1.2 Documentation

Classes

FlashStore

Typedefs

IteratorOptions

FlashStore

Kind: global class

new FlashStore([workdir])

FlashStore is a Key-Value database tool and makes using leveldb more easy for Node.js

Creates an instance of FlashStore.

Param Type Default
[workdir] string "path.join(appRoot, 'flash-store.workdir')"

Example

import { FlashStore } from 'flash-store'
const flashStore = new FlashStore('flashstore.workdir')

flashStore.put(key, value) ⇒ Promise.<void>

Put data in database

Kind: instance method of FlashStore

Param Type
key K
value V

Example

await flashStore.put(1, 1)

flashStore.get(key) ⇒ Promise.<(V\|null)>

Get value from database by key

Kind: instance method of FlashStore

Param Type
key K

Example

console.log(await flashStore.get(1))

flashStore.del(key) ⇒ Promise.<void>

Del data by key

Kind: instance method of FlashStore

Param Type
key K

Example

await flashStore.del(1)

flashStore.keys([options]) ⇒ AsyncIterableIterator.<K>

Find keys by IteratorOptions

Kind: instance method of FlashStore

Param Type Default
[options] IteratorOptions {}

Example

const flashStore = new FlashStore('flashstore.workdir')
for await(const key of flashStore.keys({gte: 1})) {
  console.log(key)
}

flashStore.values() ⇒ AsyncIterableIterator.<V>

Find all values

Kind: instance method of FlashStore
Example

const flashStore = new FlashStore('flashstore.workdir')
for await(const value of flashStore.values()) {
  console.log(value)
}

flashStore.count() ⇒ Promise.<number>

Get the counts of the database

Kind: instance method of FlashStore
Example

const count = await flashStore.count()
console.log(`database count: ${count}`)

flashStore.destroy() ⇒ Promise.<void>

Destroy the database

Kind: instance method of FlashStore

IteratorOptions

Kind: global typedef
Properties

Name Type Description
gt any Matches values that are greater than a specified value
gte any Matches values that are greater than or equal to a specified value.
lt any Matches values that are less than a specified value.
lte any Matches values that are less than or equal to a specified value.
reverse boolean Reverse the result set
limit number Limits the number in the result set.
prefix any Make the same prefix key get together.