JSPM

faster.db

1.1.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 5
    • Score
      100M100P100Q24492F
    • License Apache-2.0

    Easy to use, fast, async-ready JSON database

    Package Exports

    • faster.db
    • faster.db/lib/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (faster.db) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    FastDB

    An easy-to-use, fast, async-ready Database handler for Node.JS

    Features

    • Insert, update, delete, and retrieve data entries.
    • Supports custom events for data insertion, deletion, and errors.
    • Type-safe operations with TypeScript.
    • Automatically loads and saves data to a file.
    • Handles errors gracefully and emits appropriate events.

    Getting Started

    Prerequisites

    • Node.js (>=14.x)
    • TypeScript (>=4.x)

    Installation

    npm install faster.db

    Usage (Typescript)

    import { createDatabase } from 'faster.db';
    
    type User = {
      Name: string;
      ID: number;
    };
    
    const db = createDatabase<User>('user-database', { Name: '', ID: 0 });
    
    db.on('error', (err) => {
      console.error('Database error:', err);
    });
    
    (async () => {
      const user = await db.insert({ Name: 'John', ID: 1 });
      console.log('Inserted user:', user);
    
      const exists = await db.dataExists({ Name: 'John' });
      console.log('User exists:', exists);
    
      const allUsers = await db.getAll();
      console.log('All users:', allUsers);
    
      const deletedCount = await db.delete({ Name: 'John' });
      console.log('Deleted users count:', deletedCount);
    })();

    Usage (JavaScript)

    const { createDatabase } = require('faster.db');
    
    const db = createDatabase('user-database', { Name: String, ID: Number });
    
    db.on('error', (err) => {
      console.error('Database error:', err);
    });
    
    (async () => {
      const user = await db.insert({ Name: 'John', ID: 1 });
      console.log('Inserted user:', user);
    
      const exists = await db.dataExists({ Name: 'John' });
      console.log('User exists:', exists);
    
      const allUsers = await db.getAll();
      console.log('All users:', allUsers);
    
      const deletedCount = await db.delete({ Name: 'John' });
      console.log('Deleted users count:', deletedCount);
    })();