0.1.0 • Published 11 years ago

level-update v0.1.0

Weekly downloads
5
License
-
Repository
github
Last release
11 years ago

level-update

A levelup plugin that can be used implements conditional updates.

The name of this module may change if I think of something better.

Example

level-update' intercepts database mutations (put, del, batch), retrives the current value for that key, and passed the old value, and the new value to a user suppliedmerge` function.

The merge function can be used a number of ways - if it throws an error, the put/del/batch will callback an error.

If it returns a string or Buffer, then that value will be saved instead.

And if it returns something else, then the new value will be saved as normal.

  var Update = require('level-update')

  Update(db, function merge (oldValue, newValue) {
    
  })

  db.put('key', 'VALUE', function (err) {
    //this will be intercepted
  })

If oldValue is null, the operation is a create.

If newValue is null, the operation is a delete.

Otherwise, the operation is an update.

Use as validation / Authentication.

check that new value is correct, or throw error.

Use for versioning

check that new value comes after old, or merge concurrent updates.

License

MIT

0.1.0

11 years ago

0.0.7

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago