Advanced

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:

  1. Write your query in the editor
  2. Select the code you want to save (or save the entire editor content)
  3. Click the "Save Snippet" button or use the context menu
  4. Give your snippet a name
  5. Add optional tags for organization
  6. Click "Save"

Using Snippets

Access your saved snippets from the Snippets panel:

  1. Open the Snippets panel from the sidebar
  2. Browse or search for your snippet
  3. 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.