Skip to content

biobricks/batchlevel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Like .batch() but for all operations on a levelup database.

This lets you batch operations across multiple sublevels:

var memdb = require('memdb');
var sublevel = require('subleveldown');
var batchlevel = require('batchlevel');

var mydb = memdb();
var db = batchlevel(mydb); // batch entire db

var idb = sublevel(db, 'i'); // index
var rdb = sublevel(db, 'r'); // reverse index

idb.put('foo', 'bar', function(err) {
  if(err) return console.error(err);

  rdb.put('bar', 'foo', function(err) {
    if(err) return console.error(err);

    db.write(function(err) {
      if(err) return console.error(err);

      console.log("Wrote changes to database");
    }); 
  });
});

License and copyright

License: Apache License 2.0

Copyright 2017 BioBricks Foundation

About

batch operations on an entire leveldb database

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published