How to use leveldown - 10 common examples

To help you get started, we’ve selected a few leveldown examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / leveldown / leveldown-tests.ts View on Github external
import LevelDOWN, { Bytes } from 'leveldown';

// Can use new, or not.
const a = new LevelDOWN("/tmp/db");
const b = LevelDOWN("/tmp/db");

const db = new LevelDOWN("/tmp/db");

db.open(() => {
  db.put("key", "value", (err: Error | undefined) => { });
  db.put(Buffer.from([1]), "value", { something: true }, (err: Error | undefined) => { });

  db.get("key", (err: Error | undefined) => { });
  db.get(Buffer.from([1]), { something: true }, (err: Error | undefined, value: Bytes) => { });

  db.close((err: Error | undefined) => { });
});

db.clear((err: Error | undefined) => { });
github Picolab / pico-engine / packages / pico-engine-next / src / index.ts View on Github external
const filePath = path.resolve(home, "pico-engine.log");
  const log = configuration.log
    ? configuration.log
    : new KrlLogger(getRotatingFileStream(filePath), "");
  const rsRegistry = new RulesetRegistry(home);
  const rsEnvironment = new RulesetEnvironment(log);

  if (configuration.modules) {
    _.each(configuration.modules, function(mod, domain) {
      rsEnvironment.modules[domain] = mod;
    });
  }

  const pf = new PicoFramework({
    leveldown: leveldown(path.resolve(home, "db")) as any,

    environment: rsEnvironment,

    rulesetLoader(rid, version) {
      return rsRegistry.load(rid, version);
    },

    onStartupRulesetInitError(pico, rid, version, config, error) {
      // TODO mark it as not installed and raise an error event
      // throw error;
      console.error("TODO raise error", pico.id, rid, version, config, error);
    },

    onFrameworkEvent(ev) {
      switch (ev.type) {
        case "startup":
github orbs-network / orbs-network-typescript / projects / libs / core-library-typescript / src / block-storage / leveldb-driver.ts View on Github external
public constructor(dbPath: string) {
    // Make sure that the DB directory exists.
    const directory = path.dirname(dbPath);
    mkdirp.sync(directory);

    // Open/create the blocks LevelDB database.
    this.db = levelup.default(leveldown(dbPath));
  }
github bitpay / bitcore-node / lib / services / address / index.js View on Github external
function(next) {
      // Flush any existing mempool index
      if (fs.existsSync(self.mempoolIndexPath)) {
        leveldown.destroy(self.mempoolIndexPath, next);
      } else {
        setImmediate(next);
      }
    },
    function(next) {
github maxogden / blockplot / tests / helpers.js View on Github external
server.doorknob.db.close(function() {
    leveldown.destroy(path.join(__dirname, 'test.db'), cb)
  })
}
github mappum / webcoin / test / transactionStore.js View on Github external
function deleteStore (store, cb) {
  if (leveldown) {
    return leveldown.destroy(store.store.location, cb)
  }
  cb(null)
}
github mappum / webcoin / test / blockchain.js View on Github external
function deleteStore (store, cb) {
  if (leveldown) {
    return leveldown.destroy(store.store.location, cb)
  }
  cb(null)
}
github DefinitelyTyped / DefinitelyTyped / types / leveldown / leveldown-tests.ts View on Github external
const db = new LevelDOWN("/tmp/db");

db.open(() => {
  db.put("key", "value", (err: Error | undefined) => { });
  db.put(Buffer.from([1]), "value", { something: true }, (err: Error | undefined) => { });

  db.get("key", (err: Error | undefined) => { });
  db.get(Buffer.from([1]), { something: true }, (err: Error | undefined, value: Bytes) => { });

  db.close((err: Error | undefined) => { });
});

db.clear((err: Error | undefined) => { });

LevelDOWN.destroy("/tmp/db", (err: Error | undefined) => { });
LevelDOWN.repair("/tmp/db", (err: Error | undefined) => { });
github storj / kfs / bin / kfs.js View on Github external
async.eachSeries(sBucketList, (sBucketName, next) => {
    require('leveldown').repair(
      path.join(kfs.utils.coerceTablePath(program.db), sBucketName),
      (err) => {
        if (err) {
          process.stderr.write('[error] ' + err.message);
          process.exit(1)
        }

        process.stdout.write(sBucketName + ' (done!)\n');
        next();
      }
    );
  });
}
github molily / universal-progressive-todos / src / data / Database.js View on Github external
constructor(filename) {
    this.db = levelup(encode(leveldown(filename), {
      valueEncoding: 'json'
    }));
  }

leveldown

A low-level Node.js LevelDB binding

MIT
Latest version published 3 years ago

Package Health Score

74 / 100
Full package analysis