2.0.1 • Published 5 years ago

akv v2.0.1

Weekly downloads
236
License
MIT
Repository
github
Last release
5 years ago

akv

Build Status npm Version JS Standard

A simple key value store using single json file

Installation

$ npm install akv --save

Usage

'use strict'

const akv = require('akv')
const co = require('co')

co(function * () {
  let storage = akv('tmp/my-storage.json')
  // Set key value
  yield storage.set('foo', 'bar')

  // Get key value
  let foo = yield storage.get('foo')
  console.log(foo) // => bar
  // Delete by key
  yield storage.del('foo')
}).catch((err) => console.error(err))

Methods

Available methods

SignatureDescription
.touch() -> PromiseTouch file
.set(key, value) -> PromiseSet a value
.keys() -> PromiseGet all keys
.get(key) -> PromiseGet a value
.all() -> PromiseGet all values
.del(key) -> PromiseDelete a value
.destroy() -> PromiseDelete all values

Tips

Commit to files

Normally, akv flushes data into files with some interval. But somethings you need to explicitly call commit changes.

let storage = akv('tmp/my-storage.json')
/* ... */
storage.commit() // Force to flush files

License

This software is released under the MIT License.

Links

2.0.1

5 years ago

2.0.0

7 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.21

8 years ago

1.0.20

8 years ago

1.0.19

8 years ago

1.0.18

8 years ago

1.0.17

8 years ago

1.0.16

8 years ago

1.0.15

8 years ago

1.0.14

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.0

8 years ago