Skip to content

ministore is a mini JSON file based key-value store for node.js

License

Notifications You must be signed in to change notification settings

stagas/ministore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ministore

Installation:

npm install ministore

Usage:

// create our db
var Store = require('ministore')('../path/to/db/dir')

// create some collections
var users = Store('users')
var sessions = Store('sessions', { polling: 3000 }) // will save every 3 secs

// sync way (no callback)
users.set('john', 'doe')
users.get('john') // 'doe'

// async way
users.set('mary', 'loo', function(err) {
  users.get('mary', function(err, data) {
    console.log(data) // 'loo'
  })
})

API methods:

All API methods accept a callback as the last argument, making the process async

get(key)

set(key, val)

remove(key)

push(key, val) / unshift(key, val)

shift(key) / pop(key)

has(key)

all()

clear()

list()

length()

forEach(fn)

save()

eval(key)

evalshift(key)

evalpop(key)

Example:

var math = require('ministore')('mdb')('math')
math.set('add', function (a, b) { return a + b })
math.eval('add')(4, 5) // 9

About

ministore is a mini JSON file based key-value store for node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published