diff mod_storage_mongodb/mod_storage_mongodb.lua @ 1010:fd420237a5e4

mod_storage_mongodb: Use util.json to encode our data (handles non-string table keys, etc).
author Waqas Hussain <waqas20@gmail.com>
date Thu, 09 May 2013 11:23:07 -0400
parents 2469f779b3f7
children 853a382c9bd6
line wrap: on
line diff
--- a/mod_storage_mongodb/mod_storage_mongodb.lua	Thu May 09 13:37:55 2013 +0200
+++ b/mod_storage_mongodb/mod_storage_mongodb.lua	Thu May 09 11:23:07 2013 -0400
@@ -7,6 +7,8 @@
 local mongo = require "mongo";
 prosody.lock_globals();
 
+local json = require "util.json";
+
 local conn
 
 local keyval_store = {};
@@ -38,7 +40,7 @@
 
 	if next(data) ~= nil then -- set data
 		v.data = data;
-		return conn:insert ( namespace , v );
+		return conn:insert ( namespace , json.encode(v) );
 	else -- delete data
 		return conn:remove ( namespace , v );
 	end;