Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Fast & simple storage - a Node.js-style LevelDB wrapper (a convenience package bundling LevelUP & LevelDOWN)
The 'level' npm package is a fast and simple key-value storage library for Node.js. It provides a persistent storage solution that is easy to use and integrates well with other Node.js modules. It is built on top of LevelDB, a fast key-value storage library developed by Google.
Basic CRUD Operations
This feature allows you to perform basic Create, Read, Update, and Delete (CRUD) operations on the database. The code sample demonstrates how to put a key-value pair, retrieve a value by key, and delete a key-value pair.
const level = require('level');
const db = level('./mydb');
// Put a key-value pair
await db.put('name', 'Alice');
// Get a value by key
const value = await db.get('name');
console.log(value); // 'Alice'
// Delete a key-value pair
await db.del('name');
Batch Operations
Batch operations allow you to perform multiple operations in a single atomic action. The code sample demonstrates how to use the batch method to put and delete multiple key-value pairs in one go.
const level = require('level');
const db = level('./mydb');
// Perform batch operations
await db.batch()
.put('name', 'Alice')
.put('age', 30)
.del('name')
.write();
Streams
Streams provide a way to read and write data in a continuous flow. The code sample demonstrates how to create a read stream to iterate over all key-value pairs in the database.
const level = require('level');
const db = level('./mydb');
// Create a read stream
const stream = db.createReadStream();
stream.on('data', ({ key, value }) => {
console.log(`${key} = ${value}`);
});
NeDB is a lightweight, in-memory database that provides a MongoDB-like API. It is suitable for small projects and can be used as an embedded database. Unlike Level, NeDB stores data in memory by default, which can be less performant for large datasets.
SQLite3 is a self-contained, serverless, and zero-configuration SQL database engine. It is more feature-rich compared to Level, offering SQL query capabilities. However, it may be overkill for simple key-value storage needs.
PouchDB is an open-source JavaScript database inspired by CouchDB. It is designed to run in the browser and Node.js, providing a NoSQL database solution. PouchDB offers more advanced features like synchronization with CouchDB, which Level does not provide.
Fast & simple storage - a Node.js-style LevelDB wrapper
This is a convenience package that bundles the current release of LevelUP and LevelDOWN and exposes LevelUP on its export.
Use this package to avoid having to explicitly install LevelDOWN when you just want plain old LevelDB from LevelUP.
var level = require('level')
// 1) Create our database, supply location and options.
// This will create or open the underlying LevelDB store.
var db = level('./mydb')
// 2) put a key & value
db.put('name', 'Level', function (err) {
if (err) return console.log('Ooops!', err) // some kind of I/O error
// 3) fetch by key
db.get('name', function (err, value) {
if (err) return console.log('Ooops!', err) // likely the key was not found
// ta da!
console.log('name=' + value)
})
})
See LevelUP and LevelDOWN for more details.
Level is an OPEN Open Source Project. This means that:
Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.
See the CONTRIBUTING.md file for more details.
Level, including LevelUP & LevelDOWN, is only possible due to the excellent work of the following contributors:
Rod Vagg | GitHub/rvagg | Twitter/@rvagg |
---|---|---|
John Chesley | GitHub/chesles | Twitter/@chesles |
Jake Verbaten | GitHub/raynos | Twitter/@raynos2 |
Dominic Tarr | GitHub/dominictarr | Twitter/@dominictarr |
Max Ogden | GitHub/maxogden | Twitter/@maxogden |
Lars-Magnus Skog | GitHub/ralphtheninja | Twitter/@ralphtheninja |
David Björklund | GitHub/kesla | Twitter/@david_bjorklund |
Julian Gruber | GitHub/juliangruber | Twitter/@juliangruber |
Paolo Fragomeni | GitHub/hij1nx | Twitter/@hij1nx |
Anton Whalley | GitHub/No9 | Twitter/@antonwhalley |
Matteo Collina | GitHub/mcollina | Twitter/@matteocollina |
Pedro Teixeira | GitHub/pgte | Twitter/@pgte |
James Halliday | GitHub/substack | Twitter/@substack |
Copyright (c) 2012-2013 Level contributors (listed above).
Level is licensed under an MIT +no-false-attribs license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
FAQs
Universal abstract-level database for Node.js and browsers
We found that level demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.