ποΈ GitDB: Essential Guide & SDK Reference
Production-ready NoSQL database that stores data in Git repositories with advanced features like GraphQL, AI-powered queries, version control, and performance optimizations.
π Quick Links
π GitDB CLI Command Table
Connect | gitdb connect -t <token> -o <owner> -r <repo> | Connect CLI to a GitHub repo as your database |
List Collections | gitdb collections | List all collections (tables) |
Create Collection | gitdb create-collection <name> | Create a new collection |
Delete Collection | gitdb delete-collection <name> | Delete a collection and all its documents |
List Documents | gitdb documents <collection> | List all documents in a collection |
Create Document | gitdb create-doc <collection> <json-data> | Add a new document to a collection |
Read Document | gitdb read-doc <collection> <id> | Read a document by its ID |
Update Document | gitdb update-doc <collection> <id> <json-data> | Update a document by its ID |
Delete Document | gitdb delete-doc <collection> <id> | Delete a document by its ID |
Find Documents | gitdb find <collection> <query> | Find documents matching a MongoDB-style query |
Find One Document | gitdb findone <collection> <query> | Find a single document matching the query |
Version History | gitdb version history <collection> | Show Git commit history for a collection |
Rollback Version | gitdb version rollback <collection> --commit <hash> | Roll back a collection to a previous commit |
Start Server | gitdb server | Start the GitDB server (REST/GraphQL API) |
Start Server (bg) | gitdb server-start | Start the server in the background |
Stop Server | gitdb server-stop | Stop the server |
Server Status | gitdb server-status | Check the server status |
Enable SuperMode | gitdb supermode enable --cache-size <n> | Enable performance optimizations |
Show GraphQL Schema | gitdb graphql schema | Show the current GraphQL schema |
Interactive Shell | gitdb shell | Start an interactive shell for running commands |
Shell: Set Token | set token <token> | Set GitHub token (in shell) |
Shell: Set Owner | set owner <owner> | Set repository owner (in shell) |
Shell: Set Repo | set repo <repo> | Set repository name (in shell) |
Shell: Use Collection | use <collection> | Switch to a collection (in shell) |
Shell: Show Collections | show collections | List all collections (in shell) |
Shell: Show Docs | show docs | List documents in current collection (in shell) |
Shell: Insert | insert <JSON> | Insert a document (in shell) |
Shell: Find by ID | find <id> | Find document by ID (in shell) |
Shell: Find by Query | findone <json-query> | Find document by query (in shell) |
Shell: Count | count [json-query] | Count documents (optionally by query, in shell) |
Shell: Update | update <id> <JSON> | Update document by ID (in shell) |
Shell: Delete | delete <id> | Delete document by ID (in shell) |
Shell: Help | help | Show help (in shell) |
Shell: Exit | exit | Exit the shell |
π Getting Started
- Create a GitHub repo for your data.
- Generate a GitHub token with
repo
permissions.
- Install the CLI:
npm install -g gitdb-database
gitdb connect -t <token> -o <owner> -r <repo>
ποΈ GitDB Command Reference & Workflow Guide
1. GitDB CLI: Core Commands
Database Connection & Setup
gitdb connect -t <token> -o <owner> -r <repo>
- Connects your CLI to a GitHub repository as your database.
- Example:
gitdb connect -t ghp_abc123 -o myuser -r mydb-repo
Collection Management
gitdb collections
β List all collections
gitdb create-collection <name>
β Create a new collection
gitdb delete-collection <name>
β Delete a collection
Document Operations
gitdb documents <collection>
β List all documents in a collection
gitdb create-doc <collection> <json-data>
β Add a new document
gitdb read-doc <collection> <id>
β Read a document by ID
gitdb update-doc <collection> <id> <json-data>
β Update a document
gitdb delete-doc <collection> <id>
β Delete a document by ID
Querying
gitdb find <collection> <query>
β Find documents matching a MongoDB-style query
gitdb findone <collection> <query>
β Find a single document matching the query
Version Control & History
gitdb version history <collection>
β Show Git commit history for a collection
gitdb version rollback <collection> --commit <hash>
β Roll back a collection to a previous commit
Server Management
gitdb server
β Start the GitDB server (REST/GraphQL API)
gitdb server-start
/ gitdb server-stop
/ gitdb server-status
β Manage the server process
Advanced Features
gitdb supermode enable --cache-size <n>
β Enable performance optimizations
gitdb graphql schema
β Show the current GraphQL schema
gitdb shell
β Start an interactive shell for running commands
2. Typical GitDB Workflow
A. Initial Setup
- Create a GitHub repo for your data.
- Generate a GitHub token with
repo
permissions.
- Connect using the CLI:
gitdb connect -t <token> -o <owner> -r <repo>
B. Creating Collections & Documents
- Create collections for your data types:
gitdb create-collection users
gitdb create-collection products
gitdb create-doc users '{"name":"Alice","email":"alice@example.com"}'
gitdb create-doc products '{"name":"Laptop","price":999.99}'
C. Querying & Updating Data
gitdb find users '{"age":{"$gt":25}}'
gitdb delete-doc products <id>
D. Version Control
gitdb version rollback users --commit <hash>
E. Server/API Usage
gitdb server
- Access REST API:
http://localhost:7896/api/v1/collections/users
- Access GraphQL API:
http://localhost:7896/graphql
3. Interactive Shell Commands
Inside gitdb shell
, you can use:
set token <token>
set owner <owner>
set repo <repo>
use <collection>
create-collection <name>
show collections
show docs
insert <JSON>
find <id>
findone <json-query>
count [json-query]
update <id> <JSON>
delete <id>
help
exit
4. SDK Usage Example (JavaScript/TypeScript)
import { GitDBClient } from 'gitdb-client';
const client = new GitDBClient({
owner: 'your-github-username',
repo: 'your-repo',
token: 'your-github-token',
});
await client.insert('users', { name: 'Alice', email: 'alice@example.com' });
const users = await client.findOne('users', { name: 'Alice' });
await client.update('users', users[0].id, { age: 31 });
await client.delete('users', users[0].id);
5. Where to Find More
If you want a deep-dive into any specific command, workflow, or integration, just ask!