Skip to content

openpeeps/boogie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


A stupid simple WAL-based embedded database in Nim 👑

nimble install boogie

API reference
Github Actions Github Actions

😍 Key Features

  • BTrees storage and Hash Tables for fast lookups
  • Write-ahead log (WAL) for durability and crash recovery
  • Simple API for inserting, updating, deleting, and querying records
  • Configurable options for performance tuning, such as batch sizes and flush intervals
  • In-memory or On-disk storage modes
  • Primitive data types (string, int, float, bool, json, null)

Note

Boogie is an experimental project mostly made with the chatbot for fun and learning. It is still in early stages, so expect data loss and breaking changes. Use at your own risk.

This can be used as a simple embedded database for your Nim applications. If you want, you can use openpeeps/e2ee to encrypt the data before inserting it into Boogie database.

Examples

Here is a simple example of how to use Boogie

import pkg/boogie

var db = newStore("tests" / "data" / "myboogie.db", StorageMode.smDisk,
            enableWal = true, walFlushEveryOps = 100'u32)

# Create a table with some columns
db.createTable(newTable(
  name = "users",
  primaryKey = "id",
  columns = [
    newColumn("id", DataType.dtInt, false),
    newColumn("name", DataType.dtText, false),
    newColumn("age", DataType.dtInt, false),
    newColumn("active", DataType.dtBool, false),
    newColumn("meta", DataType.dtJson, true)
  ]
))

# insert some data
db.insertRow("users", row({
  "name": newTextValue("Alice"),
  "age": newIntValue(30),
  "active": newBoolValue(true),
  "meta": newJsonValue(%*{"hobbies": ["reading", "hiking"]})
}))

# flush the WAL to disk (when enabled)
db.checkpoint()

# Query the data
for row in db.getTable("users").get().allRows():
  for key, col in row[1]:
    echo fmt"{key}: {$col}"

Check the tests for more examples.

Todos

  • Add support for multiple tables
  • Add basic tests and benchmarks

❤ Contributions & Support

🎩 License

LGPLv3 license. Made by Humans from OpenPeeps.
Copyright OpenPeeps & Contributors — All rights reserved.