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
end end
function mongo.client( obj ) function mongo.client( conf )
obj.port = obj.port or 27017 local obj = {
host = conf.host,
port = conf.port or 27017,
}
obj.__id = 0 obj.__id = 0
obj.__sock = socketchannel.channel { obj.__sock = socketchannel.channel {
host = obj.host, host = obj.host,
port = obj.port, port = obj.port,
response = dispatch_reply, response = dispatch_reply,
auth = mongo_auth(obj), auth = mongo_auth(conf),
} }
setmetatable(obj, client_meta) setmetatable(obj, client_meta)
obj.__sock:connect() obj.__sock:connect()