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
Basics
const File = ;const db = user: 'user.db' address: 'address.db' //sync have more performance but block event loop operations, great for single file dump or a database process only servicedbusersIOMode = "async"; //async or sync options //await open allawait PromiseallObject; //you can check with .sequences or .indexes if some sequence/index existsif!dbuserssequences await dbusers; //use sequencial number await dbusers; //create index with 100k bucket size await dbusers; //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 fileuser = await dbusers;//insert address and pass user.idawait dbaddress; //update by indexawait dbaddress; //key, updated data, filter (optional), limit (optional), skip (optional), sort (optional) //update using table scanawait dbaddress; //key, updated data, filter (optional), limit (optional), skip (optional), sort (optional) //update using index + table scanawait dbaddress; //key, updated data, filter (optional), limit (optional), skip (optional), sort (optional) //filter using indexconst addresses = await dbaddress //key, filter (optional), limit (optional), skip (optional), sort (optional) await dbusers; // filter, limit (optional), skip (optional), sort (optional) //deleteByIndexawait dbaddress; //key, filter (optional), limit (optional), skip (optional), sort (optional) //deleteawait dbaddress; //filter, limit (optional), skip (optional), sort (optional) await dbusers; //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 allawait PromiseallObject;