gmsv_mongo is a high-performance MongoDB driver for Garry's Mod, enabling you to leverage the power of MongoDB for your game server data storage and management. Built with Rust for maximum performance and safety, it provides a comprehensive Lua API for all your database needs.
gmsv_mongo bridges the gap between Garry's Mod servers and MongoDB databases, allowing you to:
High Performance
Built with Rust and async I/O for optimal performance, with connection pooling and efficient BSON serialization.
Flexible Schema
MongoDB's document-based structure perfectly matches Lua's table-based data model.
Scalable
Handle millions of documents with ease. MongoDB scales with your server's needs.
Powerful Queries
Advanced querying with operators, aggregation pipelines, and full-text search support.
Data Safety
ACID transactions, automatic backups, and built-in replication for data durability.
Easy to Use
Clean, intuitive Lua API that feels natural for GMod developers.
gmsv_mongo comes packed with features designed for modern game server development:
gmsv_mongo is perfect for:
Here's a taste of what you can do with gmsv_mongo:
require("mongo")
-- Connect to MongoDB
local client = MongoDB.Client("mongodb://localhost:27017")
local db = client:Database("gameserver")
local players = db:Collection("players")
-- Save player data
local id = players:InsertOne({
steamid = "STEAM_0:1:12345",
username = "Player1",
level = 5,
credits = 1000,
inventory = {
{ item = "weapon_pistol", amount = 1 },
{ item = "ammo_pistol", amount = 50 }
}
})
-- Find high-level players
local veterans = players:Find({
level = { ["$gte"] = 10 }
}, 10)
-- Update player credits
players:UpdateOne(
{ steamid = "STEAM_0:1:12345" },
{ ["$inc"] = { credits = 500 } }
)
-- Get statistics with aggregation
local stats = players:Aggregate({
{
["$group"] = {
_id = nil,
avgLevel = { ["$avg"] = "$level" },
totalPlayers = { ["$sum"] = 1 }
}
}
})
Ready to get started? Follow our installation guide:
Install gmsv_mongo
Or explore the documentation: