1.2.0 • Published 10 years ago

mydown v1.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
10 years ago

MyDOWN

MySQL as a LevelUP backend with multi table support. Inspired from SQLdown, MyDOWN leverages node-mysql with simplified queries for better performance.

Build Status

npm install mydown

mydown = require('mydown')(database, config)

MyDOWN factory. Supply MySQL connection options and pool options as config.

//MyDOWN factory
var mydown = require('mydown')('db', {
  connectionLimit: 10,
  host: 'localhost',
  user: 'bob',
  password: 'secret'
}) 

Database needs to be created before initializing MyDOWN:

mysql -uroot -p -e "CREATE DATABASE IF NOT EXISTS db"

levelup(table, { db: mydown })

MyDOWN consumed by LevelUP, where location argument defines the table.

options.prefix

MyDOWN batch() is a transactional operation that can be applied into multiple tables, by setting the options.prefix property.

//tables a, b, c
var a = levelup('a', { db: mydown })
var b = levelup('b', { db: mydown })
var c = levelup('c', { db: mydown })

a.batch([
  { type: 'put', key: 'foo', value: 'a' },
  { type: 'put', key: 'foo', value: 'b', prefix: b }, //levelup prefix
  { type: 'put', key: 'foo', value: 'c', prefix: 'c' } //string prefix
], function () {
  a.get('foo', function (err, val) {
   //val === 'a'
  })
  b.get('foo', function (err, val) {
   //val === 'b'
  })
  c.get('foo', function (err, val) {
   //val === 'c'
  })
})

Tests

Abstract-LevelDOWN test suite is green except for 'implicit iterator snapshot'. This is because 'implicit snapshot' is not the default behavior of a transactional database. Implementing this would require more complicated query and schema, thus bad performance for very little gain in real-world use cases.

License

MIT

1.2.0

10 years ago

1.1.5

10 years ago

1.1.4

10 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.0.1

10 years ago