Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
A more practcal alternative to localStorage. db64 supports all major browsers.
import db64 from './db64.js'
try {
// First create a database with stores
await db64.create('Games', 'Super Nintendo', 'Gameboy')
// Assing a variable for modifying a store
const snes = db64.use('Games', 'Super Nintendo')
// Set multiple entries into Super Nintendo
await snes.setEntries({ adventure: 'Mario Wrold', rpg: 'Zelda', fighting: 'Street Fighter II' })
// Get multiple entries from Super Nintendo
await snes.getEntries(['adventure', 'fighting']) // { adventure: 'Mario Wrold', fighting: 'Street Fighter II' }
...
Install db64
npm i db64
Create a database with stores (string, array)
await db64.create('game-consoles', ['n64', 'ps5', 'dreamcast', 'xbox-360'])
Use a store (string, string)
const n64 = db64.use('game-consoles', 'n64')
Set an entry (IDB type, IDB type) See structured clone algorithm for supported types
await n64.set(5, 'Super Mario 64')
Set multiple entries (object | array)
await n64.setEntries({fps: 'GoldenEye 007', space: 'Star Fox 64', adventure: 'Banjo-Kazooie'})
await n64.setEntries(['Wave Race 64', 'The Legend of Zelda'])
Get an entry (IDB type)
const fps = await n64.get('fps') // GoldenEye 007
Get multiple entries (object | array)
const rareware = await n64.getEntries(['fps', 'adventure', 5]) // {fps: 'GoldenEye 007', adventure: 'Banjo-Kazooie', 0: 'Super Mario 64'}
Delete an entry (IDB type | array)
await n64.delete(1) // Deletes 'The Legend of Zelda'
Delete multiple entries
await n64.delete(['adventure', 0]) // Deletes 'Banjo-Kazooie' and 'Super Mario 64'
Clear a store (string, string)
await db64.clear('game-consoles', 'n64') // All data in n64 is deleted
Deleting existing versions of databases or object stores in IndexedDB is not feasible due to the requirement to create a new version, and old versions remain accessible. While compaction may optimize, it doesn't ensure the removal of unwanted data. db64 provides an effective solution by allowing you to clear an object store, removing all its data. This feature proves beneficial for any application, even in cases where empty stores cannot be removed. If you do require versioning consider using idb. If you're not building a progressive web app (PWA) you probably don't need versioning.
Don't hesitate just contribute, it's a tiny library we will figure it out.
MIT (c) Julien Etienne 2023
FAQs
A Practical IndexedDB API
The npm package db64 receives a total of 50 weekly downloads. As such, db64 popularity was classified as not popular.
We found that db64 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.
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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.