AI Assistant
Use AI to generate MongoDB queries, build aggregation pipelines, and analyze your database schema. Describe what you need in plain English and let AI write the MongoDB code for you.
Quick Start
Generate your first AI-powered query:
- Click the AI Assistant button in the toolbar or sidebar
- Select your target collection
- Type your request in plain English (e.g., "Find all users who signed up this month")
- Review the generated MongoDB query
- Click "Use Query" to apply it to the Query Builder or Shell
AI Query Generation
Generate MongoDB find queries from natural language descriptions. Perfect for complex filters, date ranges, and multi-condition queries.
Query Examples
| Natural Language |
Generated Query |
| "Find users with verified email" |
{ emailVerified: true } |
| "Get orders over $100 from last week" |
{ total: { $gt: 100 }, createdAt: { $gte: ISODate("...") } } |
| "Find products with stock less than 10" |
{ stock: { $lt: 10 } } |
| "Show customers from New York or California" |
{ state: { $in: ["NY", "CA"] } } |
Query Generation Features
- Schema-Aware: AI understands your collection schema and suggests valid field names
- Date Handling: Automatically converts date references like "last month" or "this year"
- Operator Selection: Chooses appropriate operators ($gt, $lt, $in, $regex, etc.)
- Nested Fields: Supports queries on nested document fields
- Array Queries: Handles array field queries with $elemMatch, $all, etc.
AI Aggregation Pipelines
Build complex aggregation pipelines by describing your data transformation in plain English.
Aggregation Examples
| Natural Language |
Generated Pipeline |
| "Total sales by category" |
$group by category, $sum sales |
| "Top 10 customers by order count" |
$group by customer, $count, $sort desc, $limit 10 |
| "Average order value per month" |
$group by month, $avg orderValue |
| "Join orders with customer details" |
$lookup from customers |
Aggregation Features
- Multi-Stage Pipelines: Generates complete pipelines with multiple stages
- Stage Optimization: Orders stages for optimal performance (e.g., $match before $group)
- Accumulator Selection: Chooses appropriate accumulators ($sum, $avg, $max, $min, etc.)
- $lookup Support: Automatically configures joins between collections
- Explain Output: Provides explanations for each generated stage
AI Schema Analysis
Get AI-powered insights into your database schema, including field types, data patterns, and optimization recommendations.
Schema Analysis Features
- Field Type Detection: Identifies field types and shows distribution
- Pattern Recognition: Detects data patterns (emails, URLs, dates, etc.)
- Relationship Detection: Finds potential relationships between collections
- Anomaly Detection: Flags inconsistent field types or unusual values
- Index Suggestions: Recommends indexes based on schema structure
Schema Insights
| Insight Type |
Description |
Field Summary |
Human-readable summary of each field's purpose and content |
Data Quality |
Percentage of documents with null/missing fields |
Relationships |
Detected foreign key relationships to other collections |
Optimization Tips |
Suggestions for improving schema design |
Conversational Context
The AI Assistant maintains conversation context, allowing you to refine queries through follow-up requests.
Conversation Examples
- User: "Find all orders from last month"
- AI: Generates query with date filter
- User: "Only show orders over $50"
- AI: Adds total > 50 condition to existing query
- User: "Sort by date descending"
- AI: Adds sort stage
Using Generated Code
Apply AI-generated queries directly to VisuaLeaf's query tools.
Apply Options
- Use in Query Builder: Opens the Visual Query Builder with the generated query pre-loaded
- Use in Aggregation: Opens the Aggregation Pipeline Builder with generated stages
- Copy to Shell: Copies the MongoDB shell command to clipboard
- Execute Directly: Run the query immediately and view results
- Save Query: Save to your query library for future use
AI Settings
Configure AI Assistant behavior and preferences.
| Setting |
Description |
Default |
Schema Context |
Include collection schema in AI requests for better accuracy |
Enabled |
Sample Documents |
Number of sample documents to include for context |
5 |
Explain Output |
Include explanations with generated code |
Enabled |
Auto-Execute |
Automatically run generated queries (with confirmation) |
Disabled |
Privacy & Security
Your data privacy is important to us:
- Schema Only: By default, only schema metadata is sent to AI—not your actual data
- Sample Opt-In: You control whether sample documents are included
- No Storage: Conversations are not stored on external servers
- Local Processing: Query execution happens locally on your machine
Pro Tips
- Be Specific: Include field names when you know them for more accurate results.
- Use Examples: "Like this: {status: 'active'}" helps AI understand your intent.
- Iterate: Start simple and refine through conversation.
- Review Output: Always review generated queries before executing on production data.
- Learn Syntax: Use AI-generated queries as a learning tool for MongoDB syntax.
Ready to try VisuaLeaf?
Download and start managing your MongoDB databases with ease.
Download Free Trial