Advanced Features
Advanced Features
Aggregation pipelines, indexes, and advanced MongoDB operations
Advanced Features
This section covers advanced MongoDB features including aggregation pipelines and index management.
Overview
gmsv_mongo provides access to MongoDB's powerful advanced features:
- Aggregation Pipelines: Complex data analysis and transformation
- Index Management: Optimize query performance
- Collection Statistics: Monitor your data
Topics
Quick Examples
Aggregation
-- Group players by class
local results = collection:Aggregate({
{
["$group"] = {
_id = "$class",
count = { ["$sum"] = 1 },
avgLevel = { ["$avg"] = "$level" }
}
}
})
Index Creation
-- Create unique index
collection:CreateIndex(
{ steamid = 1 },
true, -- unique
"steamid_unique"
)
Method Reference
| Method | Description |
|---|---|
Aggregate(pipeline) | Run aggregation pipeline |
AggregateAsync(pipeline, callback) | Async aggregation |
CreateIndex(keys, unique, name) | Create index |
ListIndexes() | List all indexes |
DropIndex(name) | Drop specific index |