A k9s-style terminal UI for MongoDB database management.
- Manage multiple MongoDB connection strings (contexts)
- Browse databases and collections interactively
- View documents with compressed or full JSON modes
- Execute MongoDB queries (basic and advanced)
- Edit documents using neovim
- Keyboard-driven navigation with shortcuts
cd longo-ui
pip install -e .longo config add --name local --connection "mongodb://localhost:27017"
longo config add --name prod --connection "mongodb://user:pass@host:27017/db?authSource=admin"longo config listlongo config remove --name localLaunch the UI:
longo?- Show help with all shortcutsq- Quit applicationc- Switch contextsd- Jump to databases viewr- Refresh current view
enter- Select item (database, collection, or document)escape- Go back one level↑/↓- Navigate up/downj/k- Navigate up/down (vim-style)
Space- Expand/collapse current document (JSON view mode)v- Toggle between JSON and table view modesV- Expand all columns with horizontal scrolling (table mode only)←/→- Scroll columns left/right (table mode only)s- Open search bar (field-specific filtering)/- Open sort bar (sort by field and direction):- Open drilldown bar (nested field selection)Ctrl+Q- Open query bar (MongoDB queries)j- View document in popup dialoge- Edit selected document in neovimx- Delete selected documentn- Next pagep- Previous page
i- Show collection info/stats
ctrl+e- Execute queryescape- Cancel query
-
Databases View (default)
- Shows all databases with collection counts
- Press
enterto select a database
-
Collections View
- Shows collections in selected database with document counts
- Press
enterto view documents in a collection - Press
escapeto go back to databases - Press
ito show collection stats
-
Documents View
- Shows documents as expandable JSON (default view)
- Press
Spaceto expand/collapse individual documents - Press
vto switch to table view mode - Press
jto view document in popup dialog - Press
eto edit document in neovim - Press
xto delete document - Press
sto search/filter documents - Press
/to sort documents - Press
Ctrl+Qto execute custom query - Press
n/pfor next/previous page - Press
escapeto go back to collections
Execute MongoDB queries using the Ctrl+Q key:
Basic queries:
collection.find({})
collection.find({"status": "active"})
collection.find({"age": {"$gt": 25}})Advanced queries:
collection.find({}).sort("name", 1)
collection.find({"status": "active"}).limit(10)
db.collection_name.aggregate([{"$group": {"_id": "$status", "count": {"$sum": 1}}}])Note: For simple sorting, use the / key (Sort Mode) instead of writing queries.
Shows documents as compact JSON, similar to MongoDB Compass:
- Each document displayed as single-line JSON (truncated at 200 chars)
- Press
Spaceto expand/collapse individual documents - Expanded documents show formatted, indented JSON
- Works perfectly with collections that have varying schemas
- Navigate with arrow keys or j/k
- Press
Spaceagain to collapse back to single-line
Example:
# Collapsed:
1 {"_id": "507f...", "name": "John", "email": "john@example.com", "address": {...}}
# Expanded (press Space):
1 {
"_id": "507f...",
"name": "John",
"email": "john@example.com",
"address": {
"street": "123 Main St",
"city": "NYC"
}
}
Shows documents in traditional column format:
- First 10 columns by default
- Values truncated to 50 characters
- Press
Vto expand all columns with horizontal scrolling - Best for collections with consistent schemas
View individual document as formatted JSON in a popup dialog.
A command bar appears at the top of the screen when activated. It has four modes:
Search Mode (s)
- Opens command bar with 🔍 Field > prompt
- Step 1: Enter field name to filter on
- Supports dot notation (e.g.,
user.address.city) - Use
ALL_FIELDSfor global search across all fields - Shows field suggestions as you type
- Press → to accept top suggestion
- Press Enter to proceed to value entry
- Supports dot notation (e.g.,
- Step 2: Enter value to search for
- Uses MongoDB queries for server-side filtering
- Searches ALL documents in collection (not just current page)
- Case-insensitive partial matching
- Real-time filtering with 2-second debounce
- Press Enter to apply filter and close command bar
- Shows total match count in header
- Supports pagination through filtered results
- ESC to close and clear filter
Sort Mode (/)
- Opens command bar with ⬍ Field > prompt
- Step 1: Enter field name to sort by
- Supports dot notation (e.g.,
user.age,metadata.createdAt) - Shows field suggestions as you type
- Press → to accept top suggestion
- Press Enter to proceed to direction entry
- Supports dot notation (e.g.,
- Step 2: Enter sort direction
- Type:
asc,desc,1, or-1 - Shows suggestions:
asc | desc - Press → to accept top suggestion
- Press Enter to apply sort and close command bar
- Type:
- Sorting persists across page navigation
- ESC to close without sorting
Query Mode (Ctrl+Q)
- Opens command bar with ⚡ prompt
- Enter MongoDB query syntax
- Press Enter to execute
- Example:
collection.find({"status": "active"}) - ESC to cancel
Drill Down Mode (:)
- Opens command bar with 🎯 prompt
- Type nested field path (e.g.,
user.address.city) - Shows suggestions below as you type
- Press → (right arrow) to accept top suggestion
- Press Enter to drill into that field
- Shows nested data as table columns
- ESC in drilldown view clears it
The command bar appears at the top when activated, with suggestions displayed below the input.
- Navigate to a document in the Documents view
- Press
eto open in neovim - Edit the JSON
- Save and quit (
:wq) - Document will be updated in MongoDB
Note: The _id field is preserved and cannot be modified.
Contexts are stored in ~/.config/longo/config.yaml:
contexts:
local: mongodb://localhost:27017
prod: mongodb://user:pass@host:27017/db
current_context: local- Python 3.8+
- MongoDB 3.6+
- neovim (for document editing)
- textual - Modern TUI framework
- pymongo - MongoDB driver
- pyyaml - Configuration management