Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@adiwajshing/keyed-db

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adiwajshing/keyed-db

Lightweight library to store an in-memory DB

  • 0.2.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @adiwajshing/keyed-db?

@adiwajshing/keyed-db is a lightweight, in-memory database that allows you to store and query data efficiently using keys. It is designed to be simple and fast, making it suitable for applications that require quick access to data without the overhead of a full-fledged database system.

What are @adiwajshing/keyed-db's main functionalities?

Creating a Database

This feature allows you to create a new instance of KeyedDB. The first argument is a comparison function to determine if two items are equal, and the second argument is a function to extract the key from an item.

const KeyedDB = require('@adiwajshing/keyed-db');
const db = new KeyedDB((a, b) => a.id === b.id, item => item.id);

Inserting Data

This feature allows you to insert data into the database. Each item must have a unique key as defined by the key extraction function.

db.insert({ id: 1, name: 'Alice' });
db.insert({ id: 2, name: 'Bob' });

Querying Data

This feature allows you to query data from the database using the key. It returns the item associated with the given key.

const item = db.get(1); // { id: 1, name: 'Alice' }

Updating Data

This feature allows you to update an existing item in the database. The item is identified by its key.

db.update({ id: 1, name: 'Alice Updated' });

Deleting Data

This feature allows you to delete an item from the database using its key.

db.delete(1);

Other packages similar to @adiwajshing/keyed-db

Keywords

FAQs

Package last updated on 24 Dec 2020

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