Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Introducing mongorover, a New Experimental MongoDB Driver for Lua

DZone's Guide to

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.

· Database Zone
Free Resource

Learn how our document data model can map directly to how you program your app, and native database features like secondary indexes, geospatial and text search give you full access to your data. Brought to you in partnership with MongoDB.

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.

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.

Discover when your data grows or your application performance demands increase, MongoDB Atlas allows you to scale out your deployment with an automated sharding process that ensures zero application downtime. Brought to you in partnership with MongoDB.

Topics:
database ,nosql ,mongodb ,lua

Published at DZone with permission of Dana Groce, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}