MongoDB database administrator for querying and inspecting the MyAssistant expenses database. Use when the user wants to query, explore, or analyze data in MongoDB, inspect collections, run aggregations, or troubleshoot data issues.
This skill requires mongosh (MongoDB Shell) to be installed and available on PATH.
Connection settings are stored in the .NET API configuration:
appsettings.json at src/expenses-api/Expenses.Api/src/appsettings.json for the MongoSettings section:
MongoSettings:ConnectionString — the MongoDB connection URIMongoSettings:Database — the database namecd src/expenses-api/Expenses.Api/src && dotnet user-secrets list
mongosh "<ConnectionString>" --eval '<query>'
# Or for interactive exploration:
mongosh "<ConnectionString>"
Always target the correct database:
mongosh "<ConnectionString>" --eval 'use("<Database>"); <query>'
Refer to references/SCHEMA.md for detailed collection schemas. Summary:
| Collection | Description |
|---|---|
Expenses | Individual expense records |
Categories | Expense category definitions |
Tags | Single document holding all tag names |
All field names are camelCase in MongoDB (via CamelCaseElementNameConvention). The _id fields are stored as ObjectId.
db.Expenses.find().sort({ timestamp: -1 }).limit(10)
db.Expenses.find({
timestamp: {
$gte: ISODate("2026-01-01"),
$lt: ISODate("2026-02-01")
}
}).sort({ timestamp: -1 })
db.Expenses.aggregate([
{ $group: { _id: "$category", total: { $sum: "$amount" } } },
{ $sort: { total: -1 } }
])
db.Expenses.aggregate([
{ $group: {
_id: { year: { $year: "$timestamp" }, month: { $month: "$timestamp" } },
total: { $sum: "$amount" },
count: { $sum: 1 }
}},
{ $sort: { "_id.year": -1, "_id.month": -1 } }
])
db.Expenses.find({ tags: "groceries" })
db.Categories.find()
db.Tags.find()
db.Expenses.aggregate([
{ $group: { _id: "$category", count: { $sum: 1 } } },
{ $sort: { count: -1 } }
])
db.Expenses.find().sort({ amount: -1 }).limit(10)
find, aggregate, count, distinct) unless the user explicitly requests a mutation.insert, update, delete, drop, or replaceOne operation, show the user the exact command and ask for explicit confirmation..limit() on queries that could return large datasets to avoid overwhelming output.mongosh command before running it.