mongo client : copy table

This commit is contained in:
Cloud Wu
2014-04-21 17:05:22 +08:00
parent 72d565dd22
commit d0dc729f4b

View File

@@ -89,14 +89,18 @@ local function mongo_auth(mongoc)
end
end
function mongo.client( obj )
obj.port = obj.port or 27017
function mongo.client( conf )
local obj = {
host = conf.host,
port = conf.port or 27017,
}
obj.__id = 0
obj.__sock = socketchannel.channel {
host = obj.host,
port = obj.port,
response = dispatch_reply,
auth = mongo_auth(obj),
auth = mongo_auth(conf),
}
setmetatable(obj, client_meta)
obj.__sock:connect()