Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dominictarr/level-trigger
triggers for levelup
https://github.com/dominictarr/level-trigger
Last synced: 23 days ago
JSON representation
triggers for levelup
- Host: GitHub
- URL: https://github.com/dominictarr/level-trigger
- Owner: dominictarr
- License: mit
- Created: 2012-12-02T03:09:54.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2015-07-14T17:27:22.000Z (over 9 years ago)
- Last Synced: 2024-10-12T23:07:17.732Z (27 days ago)
- Language: JavaScript
- Homepage:
- Size: 280 KB
- Stars: 33
- Watchers: 3
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-starred - dominictarr/level-trigger - triggers for levelup (others)
README
# level-trigger
Triggers for levelup.
Jobs must be idempotent!
If the process crashes before job has calledback,
it will be rerun the next time it's started, for consistency!## Stability
Stable: Expect bugfixes.
# Example
``` js
var db = require('levelup')('/tmp/level-trigger-example')
var SubLevel = require('level-sublevel'); SubLevel(db) //MUST install sublevel.
var Trigger = require('level-trigger')var trigDb = Trigger(db, 'example', function (ch) {
//optionally index the job with a different key.
//if there are two jobs with the same key,
//it will only be triggered once.
return ch.key
},
function (value, done) {
//call done when job is done.
done()
}
})//if you want, start the trigger in batch mode.
//this will process all the keys in the input db.//otherwise, jobs will be processed whenever a key is inserted!
if(require('optimist').argv.batch)
trigDb.start()```
## License
MIT