Skip to content

Instantly share code, notes, and snippets.

@cloudwu
Created May 14, 2014 09:11
Show Gist options
  • Save cloudwu/09f90da476f69baffd68 to your computer and use it in GitHub Desktop.
Save cloudwu/09f90da476f69baffd68 to your computer and use it in GitHub Desktop.
local skynet = require "skynet"
local mongo = require "mongo"
skynet.start(function()
local db = mongo.client { host = "127.0.0.1" , username = "user", password = "pass" }
local r = db:runCommand "listDatabases"
for k,v in ipairs(r.databases) do
print(v.name)
end
local loc = db:getDB "hello"
local c = loc.system.namespaces:find()
while c:hasNext() do
local r = c:next()
print(r.name)
end
db:disconnect()
skynet.exit()
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment