Introducing mongorover, a New Experimental MongoDB Driver for Lua
Introducing mongorover, a New Experimental MongoDB Driver for Lua
Lua is a fast and easy-to-learn scripting language. Check out this new Lua driver project for MongoDB.
Join the DZone community and get the full member experience.
Join For FreeMariaDB TX, proven in production and driven by the community, is a complete database solution for any and every enterprise — a modern database for modern applications.
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("luaMongo.MongoClient")
local client = MongoClient.new("mongodb://localhost:27017/")
local exampleDatabase = client:getDatabase("exampleDB")
local exampleCollection = exampleDatabase:getCollection("exampleCollection")
-- Create document to insert.
local document_to_insert = {foo = "bar"}
-- 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.
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.
MariaDB AX is an open source database for modern analytics: distributed, columnar and easy to use.
Published at DZone with permission of Dana Groce , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
{{ parent.title || parent.header.title}}
{{ parent.tldr }}
{{ parent.linkDescription }}
{{ parent.urlSource.name }}