gitoriaLog in with ident

mpackdb

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit8788872587888725release 1.0.7caramboleyo87888725/tests/basic.test.js

976 B

  1. import MPackDB, { PrimaryKeyType } from '../src/MPackDB.js';
  2. import { rm } from 'fs/promises';
  3. const TEST_DB_PATH = 'db/basic';
  4. console.log('--- MPackDB Test ---');
  5. // Clean up
  6. await rm(TEST_DB_PATH, { recursive: true, force: true });
  7. const db = new MPackDB(`${TEST_DB_PATH}/users`, {
  8. primaryKey: 'id',
  9. primaryKeyType: PrimaryKeyType.NUMBER
  10. });
  11. console.log('\n1. Insert records');
  12. await db.insert({ name: 'Alice', age: 30 });
  13. await db.insert({ name: 'Bob', age: 25 });
  14. await db.insert({ name: 'Charlie', age: 35 });
  15. console.log('✓ Inserted 3 records');
  16. console.log('\n2. Read all');
  17. const all = await db.find();
  18. console.log('✓ Found:', all);
  19. console.log('\n3. Find by ID');
  20. const alice = await db.find(0);
  21. console.log('✓ Found:', alice);
  22. console.log('\n4. Check file size');
  23. const { statSync } = await import('fs');
  24. const stats = statSync(`${TEST_DB_PATH}/users.mpack`);
  25. console.log(`✓ File size: ${stats.size} bytes`);
  26. console.log('\n✓ MPackDB works!');

Branches

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