
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
Simple but powerful JSON database with index and sequences capabilities, recommended for up to 1 million of registers per file/collection.
Support me for future versions:
Simple but powerful JSON database with index and sequences capabilities, recommended for up to 1 million of registers per file/collection.
Warning: do not support multiple threads/processes or multiple access to same file, open the file and keep it open, when idle close the file
How install:
npm install ggdb
const { File } = require('ggdb');
const db = {
user: new File('user.db'),
address: new File('address.db')
}
//sync have more performance but block event loop operations, great for single file dump or a database process only service
db.users.IOMode = "async"; //async or sync options
//await open all
await Promise.all(Object.values(db).map((file) => file.open()));
//you can check with .sequences or .indexes if some sequence/index exists
if(!db.users.sequences.some((sequence)=> sequence.property === 'id')){
await db.users.createSequence("id", { start: 1, increment: 1 }); //use sequencial number
await db.users.createIndex(100000, "id"); //create index with 100k bucket size
await db.users.createSequence("created_at", { type: 'Date' }); //use current date ( Date.now() )
// await db.users.createSequence("uuid", { type: 'UUID' }); //Generated unique identifier (UUID or Guid)
}
const user = {
id: 0, //will be ignored because a sequences will override these value
name: 'Ciro',
surname: 'Spaciari'
}
//insert user in users.db file
user = await db.users.add(user);
//insert address and pass user.id
await db.address.add({
address: 'Av. Whatever',
number: 1234,
state: 'SP',
city: 'São Paulo',
country: 'BR'
user_id: user.id
});
//update by index
await db.address.updateByIndex({ id: address.id }, { number: 1164 }); //key, updated data, filter (optional), limit (optional), skip (optional), sort (optional)
//update using table scan
await db.address.update((address)=> address.id > 10, { number: 1164 }); //key, updated data, filter (optional), limit (optional), skip (optional), sort (optional)
//update using index + table scan
await db.address.updateByIndex({ user_id: user.id }, { number: 1164 }, (address)=> address.id > 10); //key, updated data, filter (optional), limit (optional), skip (optional), sort (optional)
//filter using index
const addresses = await db.address.filterByIndex({ user_id: user.id }, (address)=> address.country === 'BR', 10, 0, { created_at: -1 }) //key, filter (optional), limit (optional), skip (optional), sort (optional)
await db.users.filter((user)=> user.name === 'Ciro', 1); // filter, limit (optional), skip (optional), sort (optional)
//deleteByIndex
await db.address.deleteByIndex({ id: addresses[i].id }); //key, filter (optional), limit (optional), skip (optional), sort (optional)
//delete
await db.address.deleteByIndex({ id: addresses[i].id }); //filter, limit (optional), skip (optional), sort (optional)
await db.users.delete((user)=> user.surname === 'Spaciari'); //filter, limit (optional), skip (optional), sort (optional)
//also available:
//db.users.count (same parameters as filter , returns number)
//db.users.countByIndex (same parameters as filterByIndex, returns number)
//db.users.exists (same parameters as filter, returns boolean)
//db.users.existsByIndex (same parameters as filterByIndex, returns boolean)
//await close all
await Promise.all(Object.values(db).map((file) => file.close()));
FAQs
Simple but powerful JSON database with index and sequences capabilities, recommended for up to 1 million of registers per file/collection.
We found that ggdb demonstrated a not healthy version release cadence and project activity because the last version was released 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
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.