PitchHut logo
Pocket DB
A local database for Electron and desktop apps with zero native bindings.
Pitch

Pocket DB offers a simple, efficient local database solution for Electron and CLI applications. With a MongoDB-style API and no native dependencies, get started effortlessly using just one file. Ideal for fast document storage without the need for cumbersome setups.

Description

Pocket DB is a cutting-edge local database solution, tailored for Electron, desktop, and CLI applications. It is designed to simplify the integration of persistent local storage without the need for a server or complex setup processes. This lightweight database operates with a single file and boasts zero native dependencies, ensuring a hassle-free experience for developers.

Key Features

  • Zero Native Dependencies: Built entirely in TypeScript, eliminating the need for complicated node-gyp builds or frequent rebuilds for varying Electron versions.
  • Single File Storage: Back up your entire database with ease by copying just one .pdb file, ensuring simplicity in data management.
  • MongoDB-Style API: Utilize familiar operations such as find, insert, and update, making the transition to Pocket DB seamless and intuitive for users familiar with MongoDB.
  • Append-Only Writes: Enhances performance by performing fast sequential appends, which allows for crash-safe batch operations.
  • Safe Reads: Ensures returning query results are independent copies, preventing any unintended data corruption during mutations.

Ideal Use Cases

Pocket DB is particularly well-suited for:

  • Electron and desktop applications,
  • Command-line tools,
  • Local servers,
  • Plugins and structured caches,
  • Offline-first prototypes.

However, it may not be the best choice for scenarios involving multiple processes writing to the same file or complex aggregation needs.

Quick Start Code Example

Integrating Pocket DB into a Node.js application is straightforward. Here is a simple example of how to get started:

import { pocketDb } from "@axfab/pocket-db";

const db = pocketDb("./data.pdb");
const users = db.collection("users");

// Insert a user
const { insertedId } = users.insertOne({ name: "Ada", role: "admin" });

// Query for users
const admins = users.find({ role: "admin" }).toArray();

db.close();

Performance

Pocket DB excels in write-heavy workloads, boasting impressive speed and durability. Compared to other file-backed stores, it is significantly faster for write operations and competes closely with in-memory databases for durability, owing to its innovative design that minimizes overhead during writes.

For applications where write speed, data integrity, and ease of use are paramount, Pocket DB stands out as a premier choice for developers seeking a robust local database solution.

0 comments

No comments yet.

Sign in to be the first to comment.