Coder Social home page Coder Social logo

gmsv_mongodb's Introduction

gmsv_mongodb

A MongoDB module for Garry's Mod!

Windows Linux
Build status Build Status

Quickstart

Information

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 dynamic and the queries performed are very simple. This makes MySQL a pain.

With MongoDB you don't have to worry about schemas at all! Just write and query whatever data you want!

Download

Download a pre-built binary for your system from the Releases section.

Place the .dll in garrysmod/lua/bin.

Usage

For more details see the documentation or examples.

require('mongodb')

-- Note: Connecting to the MongoDB cluster can hang! Cache the result in a global!
client = client or mongodb.Client('<CONNECTION_URI>', '<APP_NAME>')

-- Retrieve databases
local database = client:Database('test')

-- Retrieve collections
local players = database:GetCollection('players')

-- Run queries (Find, Insert, Update, Remove)
local data = players:Find({ name = 'Bob', age = 25 })

print(data[1].name)

players:Update({ name = 'Bob' }, { ['$set'] = { age = 26 } })  

-- Execute bulk queries
local bulk = players:Bulk()

for i, ply in ipairs({ 'Bob', 'Jim', 'Ann' }) do
    bulk:Insert({ name = ply, age = 20 + i })
end 

local result = bulk:Execute()

License

Code licensed under the MIT License.

gmsv_mongodb's People

Contributors

dhkatz avatar garrynewman avatar robotboy655 avatar willox avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.