{"library":"local-nosql-db","title":"Local NoSQL Database for Exploration and Education","description":"local-nosql-db is a lightweight, file-based NoSQL database designed exclusively for local development, educational purposes, and exploration. Version 1.1.7 is the current stable release, with an infrequent release cadence given its niche purpose. It stores data in JSON files, mimicking a simplified MongoDB-like API for basic CRUD operations (Create, Read, Update, Delete). Key differentiators include its extreme simplicity, zero external dependencies, and focus on providing a hands-on experience with NoSQL concepts without the overhead of a full database server. It is explicitly not recommended or suitable for production environments due to inherent limitations in scalability, concurrency handling, and data integrity guarantees. Its primary use case is isolated local data persistence for small projects or learning exercises.","language":"javascript","status":"maintenance","last_verified":"Wed Apr 22","install":{"commands":["npm install local-nosql-db"],"cli":null},"imports":["import { Database } from 'local-nosql-db';","const { Database } = require('local-nosql-db');","import type { IDocument } from 'local-nosql-db';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { Database } from 'local-nosql-db';\nimport * as path from 'path';\nimport * as fs from 'fs';\n\nconst dbPath = path.join(__dirname, 'local-db-data');\n\n// Ensure the database directory exists, or create it\nif (!fs.existsSync(dbPath)) {\n  fs.mkdirSync(dbPath, { recursive: true });\n}\n\nasync function runDbOperations() {\n  const db = new Database(dbPath);\n  await db.init(); // Initialize the database\n\n  const usersCollection = db.collection('users');\n\n  // 1. Insert a document\n  console.log('Inserting a new user...');\n  const newUser = await usersCollection.insert({\n    name: 'Alice Smith',\n    email: 'alice@example.com',\n    age: 30\n  });\n  console.log('Inserted user:', newUser);\n\n  // 2. Find documents\n  console.log('\\nFinding all users...');\n  const allUsers = await usersCollection.find({});\n  console.log('All users:', allUsers);\n\n  console.log('\\nFinding user by email...');\n  const foundUser = await usersCollection.findOne({ email: 'alice@example.com' });\n  console.log('Found user:', foundUser);\n\n  // 3. Update a document\n  if (foundUser && foundUser._id) {\n    console.log('\\nUpdating user age...');\n    const updatedUser = await usersCollection.update(\n      { _id: foundUser._id },\n      { $set: { age: 31, status: 'active' } }\n    );\n    console.log('Updated user:', updatedUser);\n  }\n\n  // 4. Delete a document\n  if (newUser && newUser._id) {\n    console.log('\\nDeleting the new user...');\n    const deleteResult = await usersCollection.delete({ _id: newUser._id });\n    console.log('Delete result:', deleteResult);\n  }\n\n  console.log('\\nFinal check of users after deletion:');\n  const remainingUsers = await usersCollection.find({});\n  console.log('Remaining users:', remainingUsers);\n\n  // Clean up the created data directory (optional)\n  // fs.rmSync(dbPath, { recursive: true, force: true });\n  // console.log('\\nDatabase directory cleaned up.');\n}\n\nrunDbOperations().catch(console.error);\n","lang":"typescript","description":"This quickstart demonstrates how to initialize the local NoSQL database, create a collection, and perform basic CRUD operations (insert, find, update, delete) on documents. It also shows how to manage the persistence directory.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}