Manual Query Editor
Manual Query Editor
Section titled “Manual Query Editor”The Manual Query Editor provides a direct command-line interface to OstrichDB for advanced users who prefer precise control over database operations. This powerful tool allows you to execute database commands using OstrichDB’s native query language.
Overview
Section titled “Overview”What is the Manual Query Editor?
Section titled “What is the Manual Query Editor?”The Manual Query Editor is:
- Command-line interface: Direct access to database operations
- Terminal-style interface: Familiar environment for developers
- Precise control: Exact specification of operations and parameters
- Advanced features: Access to all database capabilities
- Batch operations: Execute multiple commands in sequence
- Scripting support: Save and reuse command sequences
When to Use Manual Queries
Section titled “When to Use Manual Queries”Ideal for:
- Performance-critical operations requiring optimization
- Complex conditional logic not easily expressed in NLP
- Advanced filtering and sorting with specific parameters
- Bulk operations on large datasets
- Automated scripting and batch processing
- Precise control over database operations
Consider alternatives for:
- Simple data entry (use Cluster Editor)
- Exploratory queries (use Natural Language Processing)
- Visual data management (use web interface)
- Learning OstrichDB (start with visual tools)
Accessing the Manual Query Editor
Section titled “Accessing the Manual Query Editor”Navigation Methods
Section titled “Navigation Methods”Method 1: From Project Navigation
- Navigate to any project
- Click “Manual Query Editor” in the sidebar
- Terminal interface opens with project context
Method 2: From Dashboard
- Click “Advanced Tools” in the main navigation
- Select “Manual Query Editor”
- Choose project context from dropdown
Method 3: Direct URL
- Access via direct link:
/query-editor
- Bookmark for quick access
- Available from any page within OstrichDB
Interface Layout
Section titled “Interface Layout”The Manual Query Editor includes:
- Command Input: Terminal-style command prompt
- Output Display: Results and feedback area
- Context Indicator: Current project/collection context
- Command History: Previous commands with up/down arrows
- Help Panel: Quick reference for commands
- Execution Status: Success/error indicators
Query Language Syntax
Section titled “Query Language Syntax”Basic Command Structure
Section titled “Basic Command Structure”OstrichDB commands follow this general pattern:
COMMAND <target> [parameters] [modifiers]
Example:
NEW users.profiles.john_doe OF_TYPE STRING WITH "John Doe"
Command Categories
Section titled “Command Categories”Data Creation Commands
Section titled “Data Creation Commands”NEW - Create new database objects
NEW <location> [OF_TYPE <type>] [WITH <value>]
Examples:NEW ecommerce # Create projectNEW ecommerce.products # Create collectionNEW ecommerce.products.electronics # Create clusterNEW ecommerce.products.electronics.laptop # Create record (defaults to STRING)NEW users.profiles.age OF_TYPE INTEGER WITH 25 # Create typed record
Data Retrieval Commands
Section titled “Data Retrieval Commands”FETCH - Retrieve data from database
FETCH <location> [modifiers]
Examples:FETCH ecommerce # Get project infoFETCH ecommerce.products # Get collection infoFETCH ecommerce.products.electronics # Get cluster contentsFETCH ecommerce.products.electronics.laptop # Get specific record
Data Modification Commands
Section titled “Data Modification Commands”UPDATE - Modify existing data
UPDATE <location> WITH <new_value> [OF_TYPE <type>]
Examples:UPDATE users.profiles.age WITH 26UPDATE products.laptop.price WITH 999.99 OF_TYPE FLOATUPDATE settings.theme WITH "dark" OF_TYPE STRING
RENAME - Rename database objects
RENAME <old_location> TO <new_location>
Examples:RENAME users.temp TO users.archivedRENAME products.electronics.old_laptop TO products.electronics.laptop_v1
Data Deletion Commands
Section titled “Data Deletion Commands”ERASE - Delete database objects
ERASE <location>
Examples:ERASE temp_data # Delete collectionERASE users.archived.old_user # Delete specific recordERASE projects.test_project # Delete entire project
Advanced Query Features
Section titled “Advanced Query Features”Filtering and Search
Section titled “Filtering and Search”FIND - Search for records with conditions
FIND <location> WHERE <condition>
Examples:FIND users.profiles WHERE TYPE = STRINGFIND products.inventory WHERE VALUE > 100FIND sessions WHERE NAME CONTAINS "active"
COUNT - Count objects with optional conditions
COUNT <object_type> [IN <location>] [WHERE <condition>]
Examples:COUNT COLLECTIONS # Count all collectionsCOUNT RECORDS IN users.profiles # Count records in specific clusterCOUNT CLUSTERS WHERE SIZE > 1MB # Count large clusters
Metadata Operations
Section titled “Metadata Operations”SIZE_OF - Get size information
SIZE_OF <location>
Examples:SIZE_OF ecommerce # Project sizeSIZE_OF ecommerce.products # Collection sizeSIZE_OF ecommerce.products.electronics # Cluster size
TYPE_OF - Get type information
TYPE_OF <location>
Examples:TYPE_OF users.profiles.age # Returns: INTEGERTYPE_OF products.inventory.laptop # Returns: record type
INFO - Get detailed metadata
INFO <location>
Examples:INFO ecommerce # Project metadataINFO ecommerce.products.electronics # Cluster details with creation date, size, etc.
Batch Operations
Section titled “Batch Operations”BATCH - Execute multiple commands
BATCH [ COMMAND1 COMMAND2 COMMAND3]
Example:BATCH [ NEW users.batch_test NEW users.batch_test.user1 OF_TYPE STRING WITH "Alice" NEW users.batch_test.user2 OF_TYPE STRING WITH "Bob" FETCH users.batch_test]
Data Types in Queries
Section titled “Data Types in Queries”Specifying Types
Section titled “Specifying Types”When creating records, specify types using OF_TYPE
:
Basic Types:
NEW record_name OF_TYPE STRING WITH "text value"NEW record_name OF_TYPE INTEGER WITH 42NEW record_name OF_TYPE FLOAT WITH 3.14NEW record_name OF_TYPE BOOLEAN WITH trueNEW record_name OF_TYPE NULL WITH null
Date and Time Types:
NEW record_name OF_TYPE DATE WITH "2024-01-15"NEW record_name OF_TYPE TIME WITH "14:30:00"NEW record_name OF_TYPE DATETIME WITH "2024-01-15T14:30:00Z"
Special Types:
NEW record_name OF_TYPE UUID WITH "550e8400-e29b-41d4-a716-446655440000"NEW record_name OF_TYPE CREDENTIAL WITH "secret_password"
Array Types:
NEW record_name OF_TYPE []STRING WITH ["item1", "item2", "item3"]NEW record_name OF_TYPE []INTEGER WITH [1, 2, 3, 4, 5]NEW record_name OF_TYPE []BOOLEAN WITH [true, false, true]
Type Validation
Section titled “Type Validation”The query editor validates types in real-time:
- Format checking: Ensures values match type requirements
- Syntax validation: Checks command structure
- Reference validation: Verifies locations exist for operations
- Type consistency: Ensures type conversions are valid
Query Examples
Section titled “Query Examples”Basic CRUD Operations
Section titled “Basic CRUD Operations”Create a complete user profile:
# Create the structureNEW usersNEW users.profilesNEW users.profiles.john_doe
# Add profile dataNEW users.profiles.john_doe.name OF_TYPE STRING WITH "John Doe"NEW users.profiles.john_doe.email OF_TYPE STRING WITH "john@example.com"NEW users.profiles.john_doe.age OF_TYPE INTEGER WITH 30NEW users.profiles.john_doe.active OF_TYPE BOOLEAN WITH trueNEW users.profiles.john_doe.created OF_TYPE DATETIME WITH "2024-01-15T10:00:00Z"
# Verify the dataFETCH users.profiles.john_doe
Update user information:
# Update individual fieldsUPDATE users.profiles.john_doe.age WITH 31UPDATE users.profiles.john_doe.email WITH "john.doe@newcompany.com"
# Verify changesFETCH users.profiles.john_doe.ageFETCH users.profiles.john_doe.email
Search and filter operations:
# Find all active usersFIND users.profiles WHERE active = true
# Count total usersCOUNT RECORDS IN users.profiles
# Get user informationINFO users.profiles.john_doeSIZE_OF users.profiles
Advanced Operations
Section titled “Advanced Operations”Batch user creation:
BATCH [ NEW users.profiles.alice.name OF_TYPE STRING WITH "Alice Smith" NEW users.profiles.alice.email OF_TYPE STRING WITH "alice@example.com" NEW users.profiles.alice.age OF_TYPE INTEGER WITH 28 NEW users.profiles.bob.name OF_TYPE STRING WITH "Bob Johnson" NEW users.profiles.bob.email OF_TYPE STRING WITH "bob@example.com" NEW users.profiles.bob.age OF_TYPE INTEGER WITH 35 NEW users.profiles.charlie.name OF_TYPE STRING WITH "Charlie Brown" NEW users.profiles.charlie.email OF_TYPE STRING WITH "charlie@example.com" NEW users.profiles.charlie.age OF_TYPE INTEGER WITH 42]
Data migration example:
# Create new structureNEW users_v2NEW users_v2.profiles
# Copy data (manual process in current version)FETCH users.profiles.john_doe.nameNEW users_v2.profiles.john_doe.name OF_TYPE STRING WITH "John Doe"
# Rename old structureRENAME users TO users_backupRENAME users_v2 TO users
# Verify migrationFETCH users.profiles.john_doe
Command Reference
Section titled “Command Reference”Core Commands
Section titled “Core Commands”Command | Purpose | Syntax |
---|---|---|
NEW | Create objects | NEW <location> [OF_TYPE <type>] [WITH <value>] |
FETCH | Retrieve data | FETCH <location> |
UPDATE | Modify data | UPDATE <location> WITH <value> [OF_TYPE <type>] |
ERASE | Delete objects | ERASE <location> |
RENAME | Rename objects | RENAME <old> TO <new> |
Information Commands
Section titled “Information Commands”Command | Purpose | Syntax |
---|---|---|
COUNT | Count objects | COUNT <type> [IN <location>] [WHERE <condition>] |
SIZE_OF | Get size | SIZE_OF <location> |
TYPE_OF | Get type | TYPE_OF <location> |
INFO | Get metadata | INFO <location> |
Utility Commands
Section titled “Utility Commands”Command | Purpose | Syntax |
---|---|---|
HELP | Show help | HELP [command] |
VERSION | Show version | VERSION |
CLEAR | Clear terminal | CLEAR |
HISTORY | Show history | HISTORY |
System Commands
Section titled “System Commands”Command | Purpose | Syntax |
---|---|---|
CONNECT | Connect to project | CONNECT <project_name> |
STATUS | Show connection status | STATUS |
EXIT | Exit editor | EXIT |
Error Handling
Section titled “Error Handling”Common Error Types
Section titled “Common Error Types”Syntax Errors:
❌ NEW users profiles john_doe✅ NEW users.profiles.john_doe
❌ FETCH users profiles✅ FETCH users.profiles
Type Errors:
❌ NEW age OF_TYPE INTEGER WITH "twenty-five"✅ NEW age OF_TYPE INTEGER WITH 25
❌ NEW active OF_TYPE BOOLEAN WITH "yes"✅ NEW active OF_TYPE BOOLEAN WITH true
Reference Errors:
❌ FETCH nonexistent.collectionError: Collection 'nonexistent' does not exist
❌ UPDATE users.profiles.missing WITH "value"Error: Record 'missing' not found in cluster 'profiles'
Error Messages
Section titled “Error Messages”The query editor provides detailed error information:
- Error type: Syntax, reference, type, or permission error
- Error location: Specific part of command causing the issue
- Suggested fix: Recommended correction for the error
- Context information: Related information to help debug
Recovery Strategies
Section titled “Recovery Strategies”Command History:
- Use up/down arrows to navigate previous commands
- Edit and retry failed commands
- Save successful command sequences for reuse
Verification Steps:
- Use
FETCH
to verify data before operations - Use
INFO
to check object existence - Use
COUNT
to verify bulk operation results
Performance Optimization
Section titled “Performance Optimization”Efficient Query Patterns
Section titled “Efficient Query Patterns”Batch Operations:
- Group related operations into
BATCH
commands - Reduce network round-trips for multiple operations
- Atomic execution ensures consistency
Targeted Queries:
- Use specific paths rather than broad searches
- Filter early to reduce data processing
- Use appropriate data types for better performance
Connection Management:
- Maintain persistent connections for multiple queries
- Use connection pooling for high-frequency operations
- Monitor connection status with
STATUS
command
Best Practices
Section titled “Best Practices”Query Organization:
- Structure queries logically with clear intentions
- Use comments (# prefix) to document complex operations
- Test with small datasets before running on production data
- Save frequently used command sequences
Error Prevention:
- Verify paths before performing destructive operations
- Use INFO commands to understand data structure
- Test syntax with simple commands first
- Backup important data before major changes
Keyboard Shortcuts
Section titled “Keyboard Shortcuts”Navigation
Section titled “Navigation”- Up/Down arrows: Navigate command history
- Ctrl/Cmd + L: Clear terminal screen
- Tab: Auto-complete commands and paths
- Ctrl/Cmd + C: Cancel current command
Editing
Section titled “Editing”- Ctrl/Cmd + A: Select entire command line
- Ctrl/Cmd + U: Clear current line
- Ctrl/Cmd + K: Delete from cursor to end of line
- Ctrl/Cmd + W: Delete previous word
Execution
Section titled “Execution”- Enter: Execute current command
- Ctrl/Cmd + Enter: Execute command and keep in editor
- Escape: Cancel current input
Integration with Other Tools
Section titled “Integration with Other Tools”Exporting Query Results
Section titled “Exporting Query Results”Save to File:
FETCH users.profiles > user_data.jsonSIZE_OF ecommerce > project_stats.txt
Copy to Clipboard:
- Results automatically copyable from output area
- Use browser’s copy functionality for formatted results
- Export large datasets via API for external processing
API Integration
Section titled “API Integration”Command Generation:
- Manual queries can be converted to API calls
- Use query editor to prototype API operations
- Test complex operations before API implementation
Scripting Support:
- Save command sequences as scripts
- Automate repetitive operations
- Integration with external tools and workflows
Next Steps
Section titled “Next Steps”Master the Manual Query Editor by:
- Start Simple: Begin with basic NEW, FETCH, and UPDATE commands
- Practice Regularly: Use the editor for routine database operations
- Learn Shortcuts: Master keyboard shortcuts for efficiency
- Combine Tools: Use with Natural Language Processing for complex workflows
- API Integration: Apply query knowledge to REST API usage
The Manual Query Editor provides the most direct and powerful interface to OstrichDB. With practice, it becomes an indispensable tool for advanced database management and automation.