moai / luamongo

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

Update mongo_dbclient.cpp, make the command to be a table #26

Closed lywaterman closed 10 years ago

lywaterman commented 11 years ago

treat the command be a table

pakozm commented 10 years ago

What is the purpose? I don't see the use case. Thanks

lywaterman commented 10 years ago

now you can use it like this: function inc_oid(num)

local res = db:run_command(region, { cmd = 'findAndModify', ["findAndModify"] = 'etc', ["query"] = {['type']='oidbase'}, ['update'] ={['$inc'] = {['oidbase'] = mongo.NumberInt(num)}}, ['new']=true } ) return res end

pakozm commented 10 years ago

Doing this, it will be different from the documentation of MongoDB http://docs.mongodb.org/manual/reference/command/findAndModify/#dbcmd.findAndModify

I don't like to introduce these differences in the driver. It will be easy for you to implement a Lua function wrapper which does the same thing. Is it possible or I'm wrong?

pakozm commented 10 years ago

I see your point, I'm testing findAndModify using run_command method, and it is failing because the first field in bson table is not the corresponding command. Proceeding to merge the pull request. thanks!