Documentation

MingleDB is a lightweight, file-based NoSQL database family for local applications that do not need a separate database server. It runs in Node.js, Go, and Python. This page documents implemented features across mingledb (Node), mingledb-cli (interactive shell on gomingleDB), pymingledb (Python), and gomingleDB (Go).

MingleDB CLI

Interactive shell for MingleDB and gomingleDB. Open a .mgdb database file (or a directory that resolves to one) and run CRUD, schemas, and auth from the terminal. Dot commands for meta, data commands for documents.

Installation

Requires Go 1.21+ and access to the github.com/mingledb/gomingleDB module. Build the binary:

terminal
1
2
3
cd mingledb-cli
go build -o mgdb .
# Windows: go build -o mgdb.exe .

Quick start

Run ./mgdb to start with a temporary in-memory database, or run ./mgdb /path/to/app.mgdb to open a persistent file. You can also pass a directory path, which resolves to database.mgdb in that directory.

terminal
1
2
3
4
5
6
$ ./mgdb /path/to/app.mgdb

mingledb> .help
mingledb> .collections
mingledb> insert users {"name":"Alice","email":"alice@example.com","age":30}
mingledb> find users
mingledb> .exit

Dot commands

All meta-commands start with a dot.

  • .exit / .quit — Exit the shell
  • .help — Command reference
  • .databases — Current database path
  • .open PATH — Switch database path (.mgdb file or directory)
  • .collections / .tables — List collections
  • .schema [NAME] — Show schema for collection (or list schemas)
  • .auth register USER PASS — Register user
  • .auth login USER PASS — Log in
  • .auth logout — Log out
  • .auth status — Current user
  • .system CMD — Run system command (alias: .sys)
  • .output PATH — Save current in-memory data to a target path (.mgdb file or directory)

Data commands

insert collection document · find collection [filter] · findOne collection [filter] · update collection query update · delete collection query · schema collection schema_json. JSON can be inline; end a line with \ for multi-line.

terminal
1
2
3
4
5
6
7
8
9
10
11
12
13
mingledb> insert users {"name":"Alice","email":"alice@example.com","age":30}
Inserted 1 document.

mingledb> find users {"age":{"$gte":18}}
  { "name": "Alice", "email": "alice@example.com", "age": 30 }
(1 document(s))

mingledb> update users {"email":"alice@example.com"} {"age":31}
Updated 1 document.

mingledb> schema users {"name":{"type":"string","required":true},"email":{"type":"string","unique":true}}
Schema defined for users

mingledb (Node.js)

The original JavaScript implementation. Includes local persistence, schema validation on insert, basic user authentication, and query filtering.

Module support includes ESM, CommonJS, and TypeScript typings.

npm package: mingledb

Installation

terminal
1
npm install mingledb

Quick start

Create a database instance (optional: pass a directory path). Register and log in, define a schema, then use insert/find/update/delete.

index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import MingleDB from "mingledb";
const db = new MingleDB("./data/app.mgdb"); // or new MingleDB("./data")

db.registerUser("admin", "secure123");
db.login("admin", "secure123");

db.defineSchema("users", {
  name: { type: "string", required: true },
  email: { type: "string", required: true, unique: true },
  age: { type: "number" },
});

db.insertOne("users", { name: "John Doe", email: "johndoe@mingle.com", age: 25 });
console.log(db.findAll("users"));
console.log(db.findOne("users", { email: "johndoe@mingle.com" }));
db.find("users", { age: { $gte: 18, $lt: 30 } });

db.updateOne("users", { name: "John Doe" }, { age: 26 });
db.deleteOne("users", { email: "johndoe@mingle.com" });
db.logout("admin");

Schema

Use defineSchema(collectionName, schema). Each field can have type (string, number), required: true, and unique: true. required throws if the field is missing; unique ensures no duplicate values in the collection.

schema.js
1
2
3
4
5
6
db.defineSchema("posts", {
  title: { type: "string", required: true },
  slug: { type: "string", unique: true },
  views: { type: "number" },
});

Authentication API

registerUser(username, password) · login(username, password) returns boolean · isAuthenticated(username) · logout(username).

Configuration

Pass a custom path to the constructor. A directory resolves to database.mgdb; all collections are stored in that single database file.

config.js
1
const db = new MingleDB("./data");

Query operators

All implementations support core comparison and membership operators for find, findOne, updateOne, and deleteOne. Regex support differs by language runtime.

Operator Node Go Python
$gt, $gte, $lt, $lte Yes Yes Yes
$eq, $ne Yes Yes Yes
$in, $nin Yes Yes Yes
$regex + $options No (use JS RegExp value) Yes Yes
example.js
1
2
3
4
db.find("users", { age: { $gte: 18, $lt: 65 } });
db.find("users", { email: { $in: ["a@b.com", "c@d.com"] } });
// Node regex style:
db.find("users", { name: /john doe/i });

pymingledb (Python)

Python port. Same schema validation, query operators, and auth capabilities. Compatible data files with Node and Go.

PyPI package: pymingledb

Installation

terminal
1
2
uv add pymingledb
# or: pip install pymingledb

Quick start

Method names use snake_case: define_schema, insert_one, find_all, find_one, find, update_one, delete_one, register_user, login, logout, reset.

example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
from pymingledb import MingleDB

db = MingleDB("./mydb")

db.define_schema("users", {
    "name": {"type": "string", "required": True},
    "email": {"type": "string", "required": True, "unique": True},
    "age": {"type": "number"},
})
db.insert_one("users", {"name": "Alice", "email": "alice@example.com", "age": 30})
db.find_all("users")
db.find("users", {"age": {"$gte": 18, "$lt": 60}})
db.update_one("users", {"name": "Alice"}, {"age": 31})
db.register_user("admin", "secure123")
db.login("admin", "secure123")
db.logout("admin")

Schema

Define collection rules with define_schema() using field type, required, and unique options.

schema.py
1
2
3
4
5
6
db.define_schema("posts", {
    "title": {"type": "string", "required": True},
    "slug": {"type": "string", "unique": True},
    "views": {"type": "number"},
})

Authentication API

register_user(username, password) · login(username, password) · is_authenticated(username) · logout(username).

auth.py
1
2
3
4
db.register_user("admin", "secure123")
db.login("admin", "secure123")
print(db.is_authenticated("admin"))  # True
db.logout("admin")

Configuration

Set a custom data directory when creating the instance, for example MingleDB("./data") (directory) or MingleDB("./data/app.mgdb") (explicit file).

config.py
1
db = MingleDB("./data")

Query operators

Supported operators include $gt, $gte, $lt, $lte, $eq, $ne, $in, $nin, and $regex (with $options).

query.py
1
2
3
db.find("users", {"age": {"$gte": 18, "$lt": 65}})
db.find("users", {"email": {"$in": ["a@b.com", "c@d.com"]}})
db.find("users", {"name": {"$regex": "john", "$options": "i"}})

Exceptions

MingleDBError (base) · UsernameExistsError · AuthFailedError · ValidationError (schema).

gomingleDB (Go)

Go implementation. Same file format and API. Use with mingledb-cli or other ports.

Go package docs: github.com/mingledb/gomingleDB

Installation

terminal
1
go get github.com/mingledb/gomingleDB

Quick start

PascalCase method names. Use New("./data") (directory) or New("./data/app.mgdb") (explicit file), then DefineSchema, RegisterUser, Login, InsertOne, FindAll, Find, FindOne, UpdateOne, DeleteOne, Logout, Reset.

main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package main

import "github.com/mingledb/gomingleDB"

func main() {
    db := gomingleDB.New("./data")
    db.RegisterUser("admin", "secure123")
    db.Login("admin", "secure123")
    db.DefineSchema("users", gomingleDB.SchemaDefinition{
        "name":  {Type: "string", Required: true},
        "email": {Type: "string", Required: true, Unique: true},
        "age":   {Type: "number"},
    })
    db.InsertOne("users", map[string]interface{}{
        "name": "John Doe", "email": "johndoe@mingle.com", "age": 25.0,
    })
    docs, _ := db.Find("users", map[string]interface{}{
        "age": map[string]interface{}{"$gte": 18.0, "$lt": 30.0},
    })
    db.Logout("admin")
}

Schema

Define rules with DefineSchema() using SchemaDefinition and SchemaRule for field type, required, and unique constraints.

schema.go
1
2
3
4
5
6
db.DefineSchema("posts", gomingleDB.SchemaDefinition{
    "title": {Type: "string", Required: true},
    "slug":  {Type: "string", Unique: true},
    "views": {Type: "number"},
})

Authentication API

RegisterUser(username, password) · Login(username, password) · IsAuthenticated(username) · Logout(username).

auth.go
1
2
3
4
_ = db.RegisterUser("admin", "secure123")
_ = db.Login("admin", "secure123")
isAuth := db.IsAuthenticated("admin") // true
_ = isAuth
db.Logout("admin")

Configuration

Choose a database path by passing either a directory or explicit file path to gomingleDB.New(...).

config.go
1
db := gomingleDB.New("./data")

Query operators

Supports $gt, $gte, $lt, $lte, $eq, $ne, $in, $nin, and $regex (plus regex options).

query.go
1
2
3
db.Find("users", map[string]interface{}{"age": map[string]interface{}{"$gte": 18.0, "$lt": 65.0}})
db.Find("users", map[string]interface{}{"email": map[string]interface{}{"$in": []interface{}{"a@b.com", "c@d.com"}}})
db.Find("users", map[string]interface{}{"name": map[string]interface{}{"$regex": "john", "$options": "i"}})

Feature parity notes

Implemented now across mingledb, gomingleDB, and pymingledb:

  • CRUD operations on documents
  • Schema definition with type, required, and unique checks on insert
  • User registration/login/logout
  • Shared data compatibility across implementations

Not implemented yet in any port:

  • Secondary indexes
  • Transactions (begin/commit/rollback)
  • Replication or clustering

Important behavior notes: schema/unique validation currently happens on insert; update operations do not fully re-validate schema constraints. Authentication APIs exist, but CRUD methods are not automatically blocked when no user is logged in unless your application enforces that policy.