changeset 505:b6d2ac386120

Rename to mongodb
author James Callahan <james@chatid.com>
date Mon, 12 Dec 2011 21:51:29 +1100 (2011-12-12)
parents 0e9b43db7a2c
children 0e07810550c8
files mod_storage_mondodb/mod_storage_mongodb.lua mod_storage_mongodb/mod_storage_mongodb.lua
diffstat 2 files changed, 54 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/mod_storage_mondodb/mod_storage_mongodb.lua	Mon Dec 12 21:39:08 2011 +1100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-local next = next;
-local setmetatable = setmetatable;
-
-local log = require "util.logger".init("mongodb");
-local params = module:get_option("mongodb");
-
-local mongo = require "mongo";
-
-local conn = mongo.Connection.New ( true );
-conn:connect ( params.server );
-conn:auth ( params );
-
-local keyval_store = {};
-keyval_store.__index = keyval_store;
-
-function keyval_store:get(username)
-	local host, store = module.host, self.store;
-
-	local namespace = params.dbname .. "." .. host;
-	local v = { _id = { store = store ; username = username } };
-
-	local cursor , err = conn:query ( namespace , v );
-	if not cursor then return nil , err end;
-
-	local r , err = cursor:next ( );
-	if not r then return nil , err end;
-	return r.data;
-end
-
-function keyval_store:set(username, data)
-	local host, store = module.host, self.store;
-	if not host then return nil , "mongodb cannot currently be used for host-less data" end;
-
-	local namespace = params.dbname .. "." .. host;
-	local v = { _id = { store = store ; username = username } };
-
-	if next(data) ~= nil then -- set data
-		v.data = data;
-		return conn:insert ( namespace , v );
-	else -- delete data
-		return conn:remove ( namespace , v );
-	end;
-end
-
-local driver = { name = "mongodb" };
-
-function driver:open(store, typ)
-	if not typ then -- default key-value store
-		return setmetatable({ store = store }, keyval_store);
-	end;
-	return nil, "unsupported-store";
-end
-
-module:add_item("data-driver", driver);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_storage_mongodb/mod_storage_mongodb.lua	Mon Dec 12 21:51:29 2011 +1100
@@ -0,0 +1,54 @@
+local next = next;
+local setmetatable = setmetatable;
+
+local log = require "util.logger".init("mongodb");
+local params = module:get_option("mongodb");
+
+local mongo = require "mongo";
+
+local conn = mongo.Connection.New ( true );
+conn:connect ( params.server );
+conn:auth ( params );
+
+local keyval_store = {};
+keyval_store.__index = keyval_store;
+
+function keyval_store:get(username)
+	local host, store = module.host, self.store;
+
+	local namespace = params.dbname .. "." .. host;
+	local v = { _id = { store = store ; username = username } };
+
+	local cursor , err = conn:query ( namespace , v );
+	if not cursor then return nil , err end;
+
+	local r , err = cursor:next ( );
+	if not r then return nil , err end;
+	return r.data;
+end
+
+function keyval_store:set(username, data)
+	local host, store = module.host, self.store;
+	if not host then return nil , "mongodb cannot currently be used for host-less data" end;
+
+	local namespace = params.dbname .. "." .. host;
+	local v = { _id = { store = store ; username = username } };
+
+	if next(data) ~= nil then -- set data
+		v.data = data;
+		return conn:insert ( namespace , v );
+	else -- delete data
+		return conn:remove ( namespace , v );
+	end;
+end
+
+local driver = { name = "mongodb" };
+
+function driver:open(store, typ)
+	if not typ then -- default key-value store
+		return setmetatable({ store = store }, keyval_store);
+	end;
+	return nil, "unsupported-store";
+end
+
+module:add_item("data-driver", driver);