CLI Reference
Complete command reference for the Nexa CLI - an interactive terminal for NexaDB.
MySQL-Like Interactive Terminal
The Nexa CLI provides a familiar, MySQL-like interface for interacting with NexaDB. Execute queries, manage collections, and explore your data interactively.
Installation
# macOS (Homebrew)
brew install nexadb
# The nexa CLI is included automatically
# Linux (One-line installer - includes both server and CLI)
curl -fsSL https://raw.githubusercontent.com/krishcdbry/nexadb/main/install.sh | bash
# Windows
# Download from: https://github.com/krishcdbry/nexa-cli/releases/latest
# Verify installation
nexa --helpStarting the CLI
# Start NexaDB server first
nexadb start
# Connect with default credentials (localhost)
nexa -u root -p
# Password: nexadb123
# Or connect to remote server
nexa --host db.example.com --port 6970 -u root -p--hostNexaDB server host (default: localhost)--portNexaDB server port (default: 6970)-u, --usernameUsername for authentication (default: root)-p, --passwordPrompt for password (secure input)Command Reference
All commands available in the Nexa CLI with examples and descriptions.
Database Management
NexaDB now supports multiple databases. Each database can have its own collections, providing better isolation and organization for your data.
nexa(default)> databases
ā Found 3 database(s):
[1] default
[2] analytics
[3] production
# The prompt shows your current database
nexa(default)>nexa(default)> use_db analytics
ā Switched to database 'analytics'
nexa(analytics)> use_db production
ā Switched to database 'production'
nexa(production)>
# Prompt now shows 'production' as current databasenexa(default)> create_db staging
ā Database 'staging' created
nexa(default)> create_db test_env
ā Database 'test_env' created
nexa(default)> databases
ā Found 5 database(s):
[1] default
[2] analytics
[3] production
[4] staging
[5] test_envnexa(default)> drop_db test_env
ā Database 'test_env' dropped
# Warning: This permanently deletes the database and all its collections!
# Cannot drop the database you're currently usingCollection Management
nexa> use movies
ā Switched to collection 'movies'
nexa(movies)> use orders
ā Switched to collection 'orders'
nexa(orders)> nexa> collections
ā Found 3 collection(s):
* [1] movies
[2] users
[3] orders
# * indicates current collectionDocument Operations
nexa(movies)> create {"title": "The Matrix", "year": 1999, "rating": 8.7}
ā Document created: doc_abc123def456
{
"collection": "movies",
"document_id": "doc_abc123def456",
"message": "Document inserted"
}
# Create with nested objects
nexa(users)> create {"name": "Alice", "email": "alice@example.com", "profile": {"age": 30, "country": "US"}}
ā Document created: doc_xyz789# Query all documents
nexa(movies)> query {}
ā Found 3 document(s):
[1]
{
"_id": "doc_abc123",
"title": "The Matrix",
"year": 1999,
"rating": 8.7
}
# Query with filters
nexa(movies)> query {"year": {"$gte": 2000}}
ā Found 2 document(s):
[1]
{
"_id": "doc_def456",
"title": "Inception",
"year": 2010,
"rating": 8.8
}
# Query with exact match
nexa(users)> query {"name": "Alice"}
ā Found 1 document(s)
# Query with multiple conditions
nexa(movies)> query {"year": {"$gte": 2000}, "rating": {"$gte": 8.5}}nexa(movies)> update doc_abc123 {"rating": 9.0, "updated": true}
ā Document updated: doc_abc123
{
"collection": "movies",
"document_id": "doc_abc123",
"message": "Document updated"
}
# Update nested fields
nexa(users)> update doc_xyz789 {"profile": {"age": 31, "country": "US"}}
ā Document updated: doc_xyz789nexa(movies)> delete doc_abc123
ā Document deleted: doc_abc123
# Delete multiple documents (run query first, then delete each)
nexa(movies)> query {"year": {"$lt": 2000}}
# Find doc IDs, then delete one by one
nexa(movies)> delete doc_abc123
nexa(movies)> delete doc_def456# Count all documents
nexa(movies)> count
ā Document count: 125
# Count with filter
nexa(movies)> count {"year": {"$gte": 2000}}
ā Document count: 78
# Count by status
nexa(orders)> count {"status": "pending"}
ā Document count: 15Vector Search
# Basic vector search
nexa(embeddings)> vector_search [0.1, 0.95, 0.1, 0.8] 3 4
ā Found 3 similar document(s):
[1] 98.50% match
{
"_id": "doc_abc123",
"text": "Machine learning algorithms",
"embedding": [0.12, 0.94, 0.11, 0.79]
}
[2] 87.30% match
{
"_id": "doc_def456",
"text": "Artificial intelligence",
"embedding": [0.15, 0.88, 0.13, 0.82]
}
# Search with different limit
nexa(embeddings)> vector_search [0.2, 0.8, 0.3, 0.7] 10 4
ā Found 10 similar document(s):
# Higher dimensional vectors (768 dimensions for sentence transformers)
nexa(documents)> vector_search [0.01, 0.02, ..., 0.99] 5 768Query Operators
Use MongoDB-style operators in your queries for powerful filtering.
$eq (Equal)
{"age": {"$eq": 30}}$ne (Not Equal)
{"status": {"$ne": "inactive"}}$gt (Greater Than)
{"price": {"$gt": 100}}$gte (Greater Than or Equal)
{"age": {"$gte": 18}}$lt (Less Than)
{"year": {"$lt": 2000}}$lte (Less Than or Equal)
{"rating": {"$lte": 5.0}}$in (In Array)
{"status": {"$in": ["active", "pending"]}}$nin (Not In Array)
{"role": {"$nin": ["guest", "banned"]}}# Find movies from 2000 or later with rating >= 8.0
nexa(movies)> query {"year": {"$gte": 2000}, "rating": {"$gte": 8.0}}
# Find active or pending orders
nexa(orders)> query {"status": {"$in": ["active", "pending"]}}
# Find users NOT from these countries
nexa(users)> query {"country": {"$nin": ["US", "UK", "CA"]}}
# Find products priced between $10 and $100
nexa(products)> query {"price": {"$gte": 10, "$lte": 100}}
# Find users over 18 but under 65
nexa(users)> query {"age": {"$gt": 18, "$lt": 65}}System Commands
help
Display all available commands
nexa> helpexit / quit
Exit the CLI
nexa> exitTips & Tricks
š Command History
Use ā and ā arrow keys to navigate command history. Your history is saved between sessions.
āØļø Keyboard Shortcuts
Ctrl+C Cancel current command
Ctrl+D Exit CLI
Tab Auto-complete (future)
š” JSON Formatting
JSON must be valid! Use double quotes for strings, no trailing commas. The CLI will show helpful error messages if your JSON is invalid.
šÆ Current Collection
The prompt shows your current collection: nexa(movies)>Use use <collection> to switch.
Complete Example Session
$ nexa -u root -p
Password: nexadb123
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā āāāā āāāāāāāāāāāāāā āāā āāāāāā āāāāāāā āāāāāāā ā
ā āāāāā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā āāāāāā āāāāāāāāā āāāāāā āāāāāāāāāāā āāāāāāāāāāā ā
ā āāāāāāāāāāāāāāāā āāāāāā āāāāāāāāāāā āāāāāāāāāāā ā
ā āāā āāāāāāāāāāāāāāāāāā āāāāāā āāāāāāāāāāāāāāāāāāā ā
ā āāā āāāāāāāāāāāāāāāā āāāāāā āāāāāāāāāā āāāāāāā ā
ā ā
ā Database for AI Developers - v3.0.4 ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Connected to NexaDB v3.0.4
Multi-Database Architecture ā
Type 'help' for commands or 'exit' to quit.
nexa(default)> create_db entertainment
ā Database 'entertainment' created
nexa(default)> use_db entertainment
ā Switched to database 'entertainment'
nexa(entertainment)> use movies
ā Switched to collection 'movies'
nexa(entertainment:movies)> create {"title": "The Matrix", "year": 1999, "rating": 8.7, "genre": "sci-fi"}
ā Document created: doc_abc123
nexa(entertainment:movies)> create {"title": "Inception", "year": 2010, "rating": 8.8, "genre": "sci-fi"}
ā Document created: doc_def456
nexa(entertainment:movies)> create {"title": "The Shawshank Redemption", "year": 1994, "rating": 9.3, "genre": "drama"}
ā Document created: doc_ghi789
nexa(entertainment:movies)> query {}
ā Found 3 document(s):
[1]
{
"_id": "doc_abc123",
"title": "The Matrix",
"year": 1999,
"rating": 8.7,
"genre": "sci-fi"
}
...
nexa(entertainment:movies)> query {"year": {"$gte": 2000}}
ā Found 1 document(s):
[1]
{
"_id": "doc_def456",
"title": "Inception",
"year": 2010,
"rating": 8.8,
"genre": "sci-fi"
}
nexa(entertainment:movies)> count {"genre": "sci-fi"}
ā Document count: 2
nexa(entertainment:movies)> update doc_abc123 {"rating": 8.8}
ā Document updated: doc_abc123
nexa(entertainment:movies)> exit
Goodbye!