New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

subleveldown

Package Overview
Dependencies
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

subleveldown

Split a levelup database into sublevels with their own keyspace, encoding and events

  • 6.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
41K
decreased by-25.77%
Maintainers
3
Weekly downloads
 
Created

What is subleveldown?

The subleveldown package is a tool for creating sublevel partitions within a LevelDB database. It allows you to organize your data into separate namespaces, making it easier to manage and query specific subsets of your data.

What are subleveldown's main functionalities?

Creating Sublevels

This feature allows you to create a sublevel within a LevelDB database. By using subleveldown, you can partition your database into different namespaces, which helps in organizing and managing data more effectively. The code sample demonstrates how to create a sublevel and store a key-value pair in it.

const level = require('level');
const subleveldown = require('subleveldown');

const db = level('./mydb');
const subdb = subleveldown(db, 'sublevel1');

subdb.put('key', 'value', function (err) {
  if (err) return console.log('Ooops!', err);
  console.log('Value stored in sublevel1');
});

Accessing Sublevels

This feature allows you to access data stored in a specific sublevel. The code sample shows how to retrieve a value from a sublevel using the get method.

subdb.get('key', function (err, value) {
  if (err) return console.log('Ooops!', err);
  console.log('Value:', value);
});

Iterating Over Sublevels

This feature allows you to iterate over all key-value pairs in a sublevel. The code sample demonstrates how to use a read stream to access each entry in the sublevel.

subdb.createReadStream()
  .on('data', function (data) {
    console.log(data.key, '=', data.value);
  })
  .on('error', function (err) {
    console.log('Error:', err);
  })
  .on('end', function () {
    console.log('Stream ended');
  });

Other packages similar to subleveldown

Keywords

FAQs

Package last updated on 02 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc