Introducing mongorover, a New Experimental MongoDB Driver for Lua

Christopher Wang - Engineering Intern

#Technical

Lua is a fast and easy-to-learn scripting language. It is often used as a scripting engine in larger projects because it is extremely memory efficient.

So far, several MongoDB driver projects for Lua have begun, either in pure Lua or wrapping the legacy MongoDB C++ driver. This summer, I decided to begin a new Lua driver project that used the latest beta of the official MongoDB C Driver. The latest C driver includes major improvements, like asynchronous discovery of replica set members, so I wanted to jump-start a Lua driver that takes advantage of the C Driver’s recent progress.

Additionally, beginning a new Lua driver let me write a driver consistent with the latest CRUD API Specification that the official drivers support.

I’m pleased to announce an alpha release of mongorover, and I’m eager for feedback from both the Lua and MongoDB communities.

After installing the MongoDB C driver 1.2.0-dev driver (instructions in documentation), mongorover can be easily installed for Lua 5.1 or Lua 5.2 via LuaRocks:

luarocks install mongorover

After installing, you can start inserting documents like so:

local MongoClient = require("mongorover.MongoClient")
local client = MongoClient.new("mongodb://localhost:27017/")
local exampleDatabase = client:getDatabase("exampleDB")
local exampleCollection = exampleDatabase:getCollection("exampleCollection")
<p>-- Create document to insert.
local document_to_insert = {foo = "bar"}</p>
<p>-- Insert document into database
exampleCollection:insert_one(document_to_insert)
Source code and documentation (along with examples!) are available. Any feedback and/or contributions are welcome; create an issue or submit a pull request. If you have any questions, concerns, and/or helpful tips, feel free to contact me directly.


Christopher participated in our 2015 summer internship program. Are you interested in a career at MongoDB? Check out our careers page or email campus@mongodb.com.

MongoDB Careers


About the Author - Christopher

Christopher Wang is a 4th year at the Georgia Institute of Technology. This past summer, he created a new Lua driver and a MongoDB specific diagnostic agent based on the Virgo Agent Toolkit.