Installation
Prerequisites
- Go 1.26 or later
- Make (optional)
Build from Source
git clone <repository-url>
cd mddb make build cd services/mddbd
go build -o mddbd .
Running the Server
Using Make
make run make install-dev-tools
make dev make run-prod
Manual Start
cd services/mddbd ./mddbd MDDB_ADDR=":8080" MDDB_MODE="wr" MDDB_PATH="data.db" ./mddbd
First Steps
1. Add Your First Document
curl -X POST http://localhost:11023/v1/add \ -H 'Content-Type: application/json' \ -d '{ "collection": "blog", "key": "hello-world", "lang": "en_US", "meta": { "category": ["blog"], "author": ["Your Name"] }, "contentMd": "# Hello World\n\nThis is my first document in MDDB!" }'
2. Retrieve the Document
curl -X POST http://localhost:11023/v1/get \ -H 'Content-Type: application/json' \ -d '{ "collection": "blog", "key": "hello-world", "lang": "en_US" }'
3. Search Documents
curl -X POST http://localhost:11023/v1/search \ -H 'Content-Type: application/json' \ -d '{ "collection": "blog", "limit": 10 }'
4. Create a Backup
curl "http://localhost:11023/v1/backup?to=my-backup.db"
Common Use Cases
Blog/CMS Backend
curl -X POST http://localhost:11023/v1/add \ -H 'Content-Type: application/json' \ -d '{ "collection": "posts", "key": "my-first-post", "lang": "en_US", "meta": { "category": ["tech"], "tags": ["golang", "database"], "status": ["published"], "publishDate": ["2024-01-15"] }, "contentMd": "# My First Post\n\nContent here..." }' curl -X POST http://localhost:11023/v1/search \ -H 'Content-Type: application/json' \ -d '{ "collection": "posts", "filterMeta": {"status": ["published"]}, "sort": "updatedAt", "asc": false }'
Documentation System
curl -X POST http://localhost:11023/v1/add \ -H 'Content-Type: application/json' \ -d '{ "collection": "docs", "key": "getting-started", "lang": "en_US", "meta": { "section": ["introduction"], "version": ["1.0"] }, "contentMd": "# Getting Started\n\nWelcome to our documentation..." }'
Multi-language Content
curl -X POST http://localhost:11023/v1/add \ -H 'Content-Type: application/json' \ -d '{ "collection": "pages", "key": "about", "lang": "en_US", "meta": {"type": ["page"]}, "contentMd": "# About Us\n\nWe are..." }' curl -X POST http://localhost:11023/v1/add \ -H 'Content-Type: application/json' \ -d '{ "collection": "pages", "key": "about", "lang": "pl_PL", "meta": {"type": ["page"]}, "contentMd": "# O Nas\n\nJesteśmy..." }'
Configuration Examples
Read-Only Mode (for read replicas)
MDDB_MODE="read" MDDB_ADDR=":11024" ./mddbd
Custom Port and Database Path
MDDB_ADDR=":8080" MDDB_PATH="/data/mddb.db" ./mddbd
Testing the Installation
make test make test-coverage make fmt make lint
Next Steps
Troubleshooting
Port Already in Use
lsof -i :11023 MDDB_ADDR=":11024" ./mddbd
Database Locked
ps aux | grep mddbd rm mddb.db-lock
Permission Denied
chmod +x mddbd ls -la mddb.db
Getting Help