8000 GitHub - studiowebux/petitedb: In-memory with persistance local JSON database
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

studiowebux/petitedb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 |

About

In-memory with persistance local JSON database

Topics

Resources

License

Stars

Watchers

Forks

0