← スキル一覧に戻る

db-explore
by Andrew1326
⭐ 0🍴 0📅 2026年1月21日
SKILL.md
name: db-explore description: MongoDB database exploration for understanding game data, debugging, and investigation. Auto-applies when discussing database structure or debugging data issues. allowed-tools: Bash, Read
DB Explore Skill
MongoDB exploration for OpenCivilizations game.
Database Collections
| Collection | Purpose |
|---|---|
| users | Player accounts and authentication |
| bases | Player base layouts and buildings |
| clans | Alliance/clan data |
| battles | Battle replays and results |
| leaderboards | Rankings cache |
MongoDB Shell Commands
Connect
mongosh "mongodb://localhost:27017/dominations"
List Collections
db.getCollectionNames()
Sample Documents
// Get sample user
db.users.findOne()
// Get sample base with buildings
db.bases.findOne({}, { buildings: { $slice: 5 } })
// Get recent battles
db.battles.find().sort({ createdAt: -1 }).limit(5)
Count Documents
// Total users
db.users.countDocuments()
// Active players (last 7 days)
db.users.countDocuments({ lastLogin: { $gte: new Date(Date.now() - 7*24*60*60*1000) } })
Find Documents
// Find user by name
db.users.findOne({ username: "player1" })
// Find bases with specific building
db.bases.find({ "buildings.type": "townCenter" })
// Find clan members
db.clans.findOne({ name: "Warriors" }, { members: 1 })
Aggregations
// Count buildings by type across all bases
db.bases.aggregate([
{ $unwind: "$buildings" },
{ $group: { _id: "$buildings.type", count: { $sum: 1 } } },
{ $sort: { count: -1 } }
])
// Average resources per player
db.users.aggregate([
{ $group: {
_id: null,
avgGold: { $avg: "$resources.gold" },
avgFood: { $avg: "$resources.food" }
}}
])
Common Queries
Player Investigation
// Get player with full base
db.users.aggregate([
{ $match: { username: "player1" } },
{ $lookup: {
from: "bases",
localField: "_id",
foreignField: "userId",
as: "base"
}}
])
Battle Analysis
// Get battle with attacker and defender info
db.battles.aggregate([
{ $match: { _id: ObjectId("...") } },
{ $lookup: { from: "users", localField: "attackerId", foreignField: "_id", as: "attacker" } },
{ $lookup: { from: "users", localField: "defenderId", foreignField: "_id", as: "defender" } }
])
Leaderboard
// Top 10 by trophies
db.users.find({}, { username: 1, trophies: 1 })
.sort({ trophies: -1 })
.limit(10)
Important Notes
- Read-only - Never modify production data
- Use limits - Large collections need
.limit() - Index awareness - Check indexes before heavy queries
- Redis for sessions - Active game state is in Redis, not MongoDB
スコア
総合スコア
50/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です