2.0.1 • Published 6 years ago

akv v2.0.1

Weekly downloads
236
License
MIT
Repository
github
Last release
6 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

6 years ago

2.0.0

8 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.21

9 years ago

1.0.20

9 years ago

1.0.19

9 years ago

1.0.18

9 years ago

1.0.17

9 years ago

1.0.16

9 years ago

1.0.15

9 years ago

1.0.14

9 years ago

1.0.13

9 years ago

1.0.12

9 years ago

1.0.11

9 years ago

1.0.10

9 years ago

1.0.9

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.0

9 years ago