Skip to main content
Home

Built and signed on GitHub Actions

In-memory with persistance local JSON database

This package works with DenoIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
100%
Published
2 months ago (2.2.2)

Petite DB

JSR

The minimalistic NoSQL in-memory/on-disk database

Report Bug · Request Feature


About

  • Ideal for test, offline applications and Proof-of-Concept
  • Manage data in memory
  • Store and load data to/from a JSON file
  • Uses Write-Ahead Logging (WAL) to increase performance
  • Collection data is split into individual files.
  • Configurable (see table below)ù
  • Core operations:
    • Create, update, upsert, delete records
      • insertOne / insertMany
      • updateOne
      • upsert
      • deleteOne / deleteMany
    • Drop Collection
      • drop
    • Count
      • count
    • Retrieve configurable amount of random records (sample())
      • sample
    • Snapshot and Clear data
      • getData
      • clear
    • Support Typescript Types: Data (Schema) and Collections (string)
  • Support Saving BigInt in JSON file
  • Added _meta object for each record (not fully implemented)
    • createdAt
    • updatedAt
    • Version (increase when update and upsert)
  • Added simple indexing (by _id)

Installation and Usage

  1. Install deno: https://deno.com
  2. deno add @studiowebux/petitedb
  3. import { PetiteDB } from "@studiowebux/petitedb@^2.1.2";

 Version 2.2.0+ has breaking changes.

Example:

see demo/ directory, there are many examples.

Clean Shutdown

const db = new PetiteDB(...);

await db.shutdown()

Options

Parameter Description Default
autoCommit  If true, the database will be commited automatically when maxWritesBeforeFlush is reached true
walLogPath  WAL File name db_name.wal.log
maxWritesBeforeFlush   Number of entries to store in the WAL before saving on-disk  100
memoryOnly   Ephemeral DB only false
verbose  Enables all log levels false

Contributing

  1. Fork the project
  2. Create a Feature Branch
  3. Commit your changes
  4. Push your changes
  5. Create a PR
Working with your local branch

Branch Checkout:

git checkout -b <feature|fix|release|chore|hotfix>/prefix-name

Your branch name must starts with [feature|fix|release|chore|hotfix] and use a / before the name; Use hyphens as separator; The prefix correspond to your Kanban tool id (e.g. abc-123)

Keep your branch synced:

git fetch origin
git rebase origin/master

Commit your changes:

git add .
git commit -m "<feat|ci|test|docs|build|chore|style|refactor|perf|BREAKING CHANGE>: commit message"

Follow this convention commitlint for your commit message structure

Push your changes:

git push origin <feature|fix|release|chore|hotfix>/prefix-name

Examples:

git checkout -b release/v1.15.5
git checkout -b feature/abc-123-something-awesome
git checkout -b hotfix/abc-432-something-bad-to-fix
git commit -m "docs: added awesome documentation"
git commit -m "feat: added new feature"
git commit -m "test: added tests"

License

Distributed under the MIT License. See LICENSE for more information.

Contact

| Buy Me A Coffee | Webux Logo Webux Lab |
Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@studiowebux/petitedb

Import symbol

import * as petitedb from "@studiowebux/petitedb";
or

Import directly with a jsr specifier

import * as petitedb from "jsr:@studiowebux/petitedb";

Add Package

pnpm i jsr:@studiowebux/petitedb
or (using pnpm 10.8 or older)
pnpm dlx jsr add @studiowebux/petitedb

Import symbol

import * as petitedb from "@studiowebux/petitedb";

Add Package

yarn add jsr:@studiowebux/petitedb
or (using Yarn 4.8 or older)
yarn dlx jsr add @studiowebux/petitedb

Import symbol

import * as petitedb from "@studiowebux/petitedb";

Add Package

vlt install jsr:@studiowebux/petitedb

Import symbol

import * as petitedb from "@studiowebux/petitedb";

Add Package

npx jsr add @studiowebux/petitedb

Import symbol

import * as petitedb from "@studiowebux/petitedb";

Add Package

bunx jsr add @studiowebux/petitedb

Import symbol

import * as petitedb from "@studiowebux/petitedb";