mpackdb
All repositories: gitoria
1.0 KB
import MPackDB from '../src/MPackDB.js';import { rm } from 'fs/promises';await rm('find-test', { recursive: true, force: true });const db = new MPackDB('find-test/db', {primaryKey: '*id',indexPersistThreshold: 10000000,indexPersistInterval: 0});console.log('Insert 10000 records...');for (let i = 0; i < 10000; i++) {await db.insert({ value: i });}console.log('Count before delete:');let count1 = 0;for await (const rec of db.find()) count1++;console.log(` Found: ${count1}`);console.log('\nDelete 500 records (ids 1000-1499)...');const toDelete = new Set([...Array.from({length:500}, (_,i) => i+1000)]);await db.delete(r => toDelete.has(r.id));console.log('\nCount after delete:');let count2 = 0;for await (const rec of db.find()) count2++;console.log(` Found: ${count2} (expected 9500)`);console.log('\nCount again:');let count3 = 0;for await (const rec of db.find()) count3++;console.log(` Found: ${count3} (expected 9500)`);await db.close();await rm('find-test', { recursive: true, force: true });
Branches
- mastermain branch
Latest commits
- cde73eb4release 1.0.6caramboleyo
- d01dda02add index hints, intersection, boundingBox; remove findByIndexcaramboleyo
- b8ffc1a0release 1.0.5caramboleyo
- d47876a1reimplemented lost features like indexed find and more testscaramboleyo
- 7f08da9afixed insert ignoring model definitioncaramboleyo
- 705774a9added flush before findcaramboleyo
- b4db6391initial commitcaramboleyo