UNPKG

bsonicdb

Version:

=========

67 lines (48 loc) 1.87 kB
# BsonicDB ========= BsonicDB is a lightweight, high-performance, caching-based NoSQL database designed for efficient read and write operations. This database is optimized for both small and large data sets and supports various essential database operations like insert, update, find, and delete. Features -------- - Fast read/write performance. - Efficient in-memory caching with configurable durations. - Supports inserting, updating, deleting, and finding documents. - Bulk insert operations (`insertMany`). - Easily integrated into Node.js applications. Installation ----------- To install BsonicDB, run the following command: npm install bsonicdb Usage ----- Here's an example of how to use BsonicDB: ```javascript const BsonicDB = require('bsonicdb'); // Initialize the database with path and caching options const db = new BsonicDB({ path: './data', cacheDuration: 100, // Caches data for 100 milliseconds before writing to disk }); // Initialize the database db.initialize().then(async () => { console.log('BsonicDB Initialized!'); // Insert a document into a collection await db.insert('users', { name: 'John', age: 30 }); // Insert multiple documents into a collection await db.insertMany('users', [ { name: 'Alice', age: 25 }, { name: 'Bob', age: 28 } ]); // Find documents in a collection const allUsers = await db.find('users', {}); console.log('All Users:', allUsers); // Find specific documents with a query const youngUsers = await db.find('users', { age: { $lt: 30 } }); console.log('Young Users:', youngUsers); // Update a document await db.update('users', { name: 'John' }, { age: 31 }); // Delete a document await db.delete('users', { name: 'Bob' }); // Clear the entire collection await db.clear('users'); }); ```