mpackdb
All repositories: gitoria
1.3 KB
import MPackDB from '../src/MPackDB.js';import { rm } from 'fs/promises';const TEST_DB_PATH = 'db/lockfile';console.log('--- Lockfile Test ---');// Clean upawait rm(TEST_DB_PATH, { recursive: true, force: true });const db = new MPackDB(`${TEST_DB_PATH}/db`);// Test 1: Insertconsole.log('Test 1: Insert with lock');const id1 = await db.insert({ name: 'Alice', age: 30 });console.log('✓ Inserted:', id1);// Test 2: Multiple insertsconsole.log('\nTest 2: Multiple inserts');const id2 = await db.insert({ name: 'Bob', age: 25 });const id3 = await db.insert({ name: 'Charlie', age: 35 });console.log('✓ Inserted:', id2, id3);// Test 3: Read (no lock needed)console.log('\nTest 3: Read all');const all = await db.find();console.log('✓ Found', all.length, 'records');// Test 4: Delete with lockconsole.log('\nTest 4: Delete with lock');await db.delete(u => u.age === 25);const remaining = await db.find();console.log('✓ Remaining:', remaining.length, 'records');// Test 5: Verify no stale lockconsole.log('\nTest 5: Verify lock cleanup');const { readdirSync } = await import('fs');const files = readdirSync(TEST_DB_PATH);const hasLock = files.some(f => f.endsWith('.lock'));if (hasLock) {throw new Error('❌ Lock file not cleaned up!');}console.log('✓ No stale lock files');console.log('\n✓ All tests passed!');
Branches
- mastermain branch
Latest commits
- 87888725release 1.0.7caramboleyo
- c4cdb9b6node: import prefixes (Deno compat) + pre-existing index-state WIPcaramboleyo
- 0afb8f4bupdate now must be a callbackcaramboleyo
- 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