Query Snippets
Save, organize, and reuse your MongoDB queries.
Overview
Snippets let you save frequently used queries for quick access. Organize them with tags and search to find what you need instantly.
Saving Snippets
To save a query as a snippet:
- Write your query in the editor
- Select the code you want to save (or save the entire editor content)
- Click the "Save Snippet" button or use the context menu
- Give your snippet a name
- Add optional tags for organization
- Click "Save"
Using Snippets
Access your saved snippets from the Snippets panel:
- Open the Snippets panel from the sidebar
- Browse or search for your snippet
- Click a snippet to insert it into the editor
Tip: Double-click a snippet to insert it at the cursor position without replacing existing content.
Organizing with Tags
Tags help you categorize and find snippets quickly. Common tagging strategies:
By Database/Collection
Tags: users, orders, products By Operation Type
Tags: read, write, aggregation, admin By Project
Tags: project-alpha, analytics, migrations By Frequency
Tags: daily, weekly, debugging Searching Snippets
Use the search box in the Snippets panel to filter by:
- Snippet name
- Tag names
- Query content
Example Snippets
Find Active Users
// Find active users with recent login
db.users.find({
status: "active",
lastLogin: { $gte: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000) }
}).sort({ lastLogin: -1 }) Order Statistics
// Get order statistics by status
db.orders.aggregate([
{ $group: {
_id: "$status",
count: { $sum: 1 },
totalValue: { $sum: "$total" },
avgValue: { $avg: "$total" }
}},
{ $sort: { count: -1 } }
]) Find Duplicates
// Find duplicate emails
db.users.aggregate([
{ $group: {
_id: "$email",
count: { $sum: 1 },
ids: { $push: "$_id" }
}},
{ $match: { count: { $gt: 1 } } }
]) Index Usage
// Check index usage statistics
db.collection.aggregate([
{ $indexStats: {} }
]) Managing Snippets
Editing Snippets
Right-click a snippet and select "Edit" to modify its name, tags, or content.
Deleting Snippets
Right-click a snippet and select "Delete" to remove it. This action cannot be undone.
Copying Snippets
Click the copy button on any snippet to copy its content to the clipboard without inserting it into the editor.
Snippet Storage
Snippets are stored locally in Sutido's SQLite database. They persist across application restarts but are not synced to the cloud.
Data Location
On Windows, snippets are stored in:
%APPDATA%/sutido/ Best Practices
Use Descriptive Names
Name snippets clearly so you can identify them later:
- Good: "Find users without email verification"
- Bad: "query1"
Add Comments
Include comments in your snippets explaining what they do and any parameters that need to be modified:
// Find orders in date range
// Change startDate and endDate as needed
db.orders.find({
createdAt: {
$gte: ISODate("2026-01-01"), // startDate
$lt: ISODate("2026-02-01") // endDate
}
}) Keep Snippets Focused
Save small, reusable queries rather than large scripts. You can combine multiple snippets as needed.
Next Steps
Learn about Schema Analysis to understand your data structure.