Insight O' Mate

Query examples

40+ natural language database query examples.

Browse real examples of plain-English questions translated into MongoDB aggregation pipelines, Firestore queries, Redis commands, DynamoDB expressions, and Excel aggregations \u2014 all generated by Insight O\u2019 Mate.

MongoDB query examples

Plain English → MongoDB aggregation pipelines, find queries, and countDocuments

Insight O' Mate translates natural language questions into native MongoDB query syntax. These examples demonstrate how plain English prompts are converted into $match, $group, $lookup, and other complex aggregation pipeline stages.

Q

Top 10 customers by total spending this month

db.orders.aggregate([
  { $match: { createdAt: { $gte: startOfMonth } } },
  { $group: { _id: "$customerId", total: { $sum: "$amount" } } },
  { $sort: { total: -1 } },
  { $limit: 10 }
])
Q

Count orders placed in the last 7 days

db.orders.countDocuments({
  createdAt: { $gte: new Date(Date.now() - 7*24*60*60*1000) }
})
Q

Users who signed up but never placed an order

db.users.aggregate([
  { $lookup: { from: "orders", localField: "_id",
      foreignField: "userId", as: "orders" } },
  { $match: { orders: { $size: 0 } } }
])
Q

Orders grouped by status with count

db.orders.aggregate([
  { $group: { _id: "$status", count: { $sum: 1 } } },
  { $sort: { count: -1 } }
])
Q

Top 5 products by revenue

db.orders.aggregate([
  { $unwind: "$items" },
  { $group: { _id: "$items.productId",
      revenue: { $sum: { $multiply: ["$items.price", "$items.quantity"] } } } },
  { $sort: { revenue: -1 } },
  { $limit: 5 }
])
Q

Users created in last 30 days with unverified emails

db.users.find({
  createdAt: { $gte: new Date(Date.now() - 30*24*60*60*1000) },
  emailVerified: false
})
Q

Distinct values in the 'category' field

db.products.distinct("category")
Q

Users with more than 3 orders this month

db.orders.aggregate([
  { $match: { createdAt: { $gte: startOfMonth } } },
  { $group: { _id: "$userId", count: { $sum: 1 } } },
  { $match: { count: { $gt: 3 } } }
])

Firebase Firestore query examples

Plain English → Firestore collection queries with where filters, orderBy, and count()

These examples show how Insight O' Mate generates Firestore Admin SDK queries, automatically handling compound where clauses, orderBy constraints, and pagination limits from conversational input.

Q

Active users who joined in the last 30 days

db.collection("users")
  .where("status", "==", "active")
  .where("createdAt", ">=", thirtyDaysAgo)
  .orderBy("createdAt", "desc")
  .get()
Q

Count pending orders

db.collection("orders")
  .where("status", "==", "pending")
  .count().get()
Q

Blog posts tagged 'AI' ordered by publish date

db.collection("posts")
  .where("tags", "array-contains", "AI")
  .orderBy("publishedAt", "desc")
  .limit(20).get()
Q

Users from India

db.collection("users")
  .where("country", "==", "India")
  .get()
Q

Products with inventory below 10

db.collection("products")
  .where("stock", "<", 10)
  .orderBy("stock", "asc")
  .get()
Q

5 most recent open support tickets

db.collection("tickets")
  .where("status", "==", "open")
  .orderBy("createdAt", "desc")
  .limit(5).get()
Q

Orders created today

db.collection("orders")
  .where("createdAt", ">=", startOfDay)
  .orderBy("createdAt", "desc")
  .get()

Redis query examples

Plain English → Redis commands for Hashes, Sorted Sets, Lists, Sets, and Streams

Insight O' Mate acts as an AI Redis copilot. It infers the correct data structure command (e.g., ZRANGEBYSCORE, HGETALL) and safely utilizes SCAN for key pattern matching to prevent event loop blocking.

Q

Users with score above 1000 in the leaderboard

ZRANGEBYSCORE leaderboard 1000 +inf WITHSCORES
Q

Profile for user:42

HGETALL user:42
Q

How many keys match session:* pattern

SCAN 0 MATCH session:* COUNT 100
# Iterate until cursor returns 0
Q

5 most recent messages in chat:room1 stream

XREVRANGE chat:room1 + - COUNT 5
Q

All members of the 'admins' set

SMEMBERS admins
Q

Last 20 items from the notifications list

LRANGE notifications -20 -1
Q

TTL for session:abc123

TTL session:abc123
Q

Top 3 leaderboard entries with scores

ZREVRANGE leaderboard 0 2 WITHSCORES

Amazon DynamoDB query examples

Plain English → DynamoDB Query/Scan with automatic expression and reserved-word handling

Generating DynamoDB JSON syntax can be tedious. These examples illustrate how the AI automatically handles ExpressionAttributeNames and ExpressionAttributeValues for complex filter expressions.

Q

All orders for customer 'user-123' in the last 30 days

{
  TableName: "orders",
  KeyConditionExpression:
    "customerId = :cid AND createdAt >= :date",
  ExpressionAttributeValues: {
    ":cid": { S: "user-123" },
    ":date": { S: thirtyDaysAgo.toISOString() }
  }
}
Q

Electronics products under $100

{
  TableName: "products",
  FilterExpression:
    "#cat = :category AND #price < :max",
  ExpressionAttributeNames: {
    "#cat": "category", "#price": "price"
  },
  ExpressionAttributeValues: {
    ":category": { S: "Electronics" },
    ":max": { N: "100" }
  }
}
Q

Count of active subscriptions

{
  TableName: "subscriptions",
  FilterExpression: "#status = :active",
  ExpressionAttributeNames: { "#status": "status" },
  ExpressionAttributeValues: { ":active": { S: "active" } },
  Select: "COUNT"
}
Q

Most recent order for customer 'user-456'

{
  TableName: "orders",
  KeyConditionExpression: "customerId = :cid",
  ExpressionAttributeValues: { ":cid": { S: "user-456" } },
  ScanIndexForward: false,
  Limit: 1
}
Q

Users whose name starts with 'Alex'

{
  TableName: "users",
  FilterExpression: "begins_with(#name, :prefix)",
  ExpressionAttributeNames: { "#name": "name" },
  ExpressionAttributeValues: { ":prefix": { S: "Alex" } }
}
Q

Payments between $100 and $500

{
  TableName: "payments",
  FilterExpression: "#amount BETWEEN :min AND :max",
  ExpressionAttributeNames: { "#amount": "amount" },
  ExpressionAttributeValues: {
    ":min": { N: "100" }, ":max": { N: "500" }
  }
}

Excel & CSV query examples

Plain English → In-memory aggregations, filters, and cross-sheet joins

Without relying on VLOOKUP or pivot tables, Insight O' Mate parses spreadsheets locally and performs SQL-like aggregations, filtering, and cross-sheet joins entirely in memory based on English prompts.

Q

Total revenue by product category

GROUP BY category
SUM(revenue) AS total_revenue
ORDER BY total_revenue DESC
Q

Customers who spent more than $500 this month

FILTER WHERE
  order_date >= first_day_of_month
  AND total_amount > 500
Q

Join Orders sheet with Customers sheet by CustomerID

JOIN Orders ON
  Orders.CustomerID = Customers.CustomerID
Q

Average order value by month in 2024

GROUP BY MONTH(order_date)
WHERE YEAR(order_date) = 2024
AVG(order_total) AS avg_order_value
ORDER BY month ASC
Q

Count rows where status is 'Approved'

COUNT(*) WHERE status = 'Approved'
Q

Duplicate email addresses in contacts

GROUP BY email
HAVING COUNT(*) > 1
SELECT email, COUNT(*) AS occurrences
Q

Top 10 products by quantity sold

GROUP BY product_name
SUM(quantity) AS total_quantity
ORDER BY total_quantity DESC
LIMIT 10
Q

Total expenses per department

GROUP BY department
SUM(amount) AS total_expenses
ORDER BY total_expenses DESC

Try these queries with your own data

Connect your own MongoDB, Firestore, Redis, DynamoDB, or spreadsheet and start asking questions in plain English.