- Notifications
You must be signed in to change notification settings - Fork5
A MongoDB module for Garry's Mod
License
NotificationsYou must be signed in to change notification settings
dhkatz/gmsv_mongodb
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A MongoDB module for Garry's Mod!
Windows | Linux |
---|---|
Why does Garry's Mod need a MongoDB module? Because MongoDB is a NoSQL database.MySQL is designed for static schemas and performs best with complex queries.
Typically, the data stored by Garry's Mod servers is extremely dynamicand the queries performed are very simple. This makes MySQL a pain.
With MongoDB you don't have to worry about schemas at all! Just writeand query whatever data you want!
Download a pre-built binary for your system from theReleases section.
Place the.dll
ingarrysmod/lua/bin
.
For more details see thedocumentation orexamples.
require('mongodb')-- Note: Connecting to the MongoDB cluster can hang! Cache the result in a global!client=clientormongodb.Client('<CONNECTION_URI>','<APP_NAME>')-- Retrieve databaseslocaldatabase=client:Database('test')-- Retrieve collectionslocalplayers=database:GetCollection('players')-- Run queries (Find, Insert, Update, Remove)localdata=players:Find({name='Bob',age=25 })print(data[1].name)players:Update({name='Bob'}, { ['$set']= {age=26 } })-- Execute bulk querieslocalbulk=players:Bulk()fori,plyinipairs({'Bob','Jim','Ann'})dobulk:Insert({name=ply,age=20+i })endlocalresult=bulk:Execute()
Code licensed under theMIT License.
About
A MongoDB module for Garry's Mod
Topics
Resources
License
Stars
Watchers
Forks
Packages0
No packages published