moai / luamongo

Lua driver for mongodb
https://github.com/moai/luamongo
MIT License
170 stars 58 forks source link

How to query and sort ? #14

Closed dome closed 12 years ago

larubbio commented 12 years ago

To query you would do something like this:

mongodb:query("database.collection", {field=value})

To sort:

mongodb:query("database.collection", {query = {field=value}, orderby = {field = 1}})

To reverse the sort use -1. You can orderby more than one field.