Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/resty/mongol/bson.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ local new_object_id = obid.new
local object_id_mt = obid.metatable
local binary_mt = {}
local utc_date = {}
local bson_null = {}


local function read_document ( get , numerical )
Expand Down Expand Up @@ -68,7 +69,7 @@ local function read_document ( get , numerical )
elseif op == "\9" then -- UTC datetime milliseconds
v = le_uint_to_num ( get ( 8 ) , 1 , 8 )
elseif op == "\10" then -- Null
v = nil
v = bson_null
elseif op == "\16" then --int32
v = le_int_to_num ( get ( 4 ) , 1 , 8 )
elseif op == "\17" then --int64
Expand Down Expand Up @@ -209,8 +210,9 @@ function to_bson(ob)
end

return {
from_bson = from_bson ;
to_bson = to_bson ;
from_bson = from_bson;
to_bson = to_bson;
bson_null = bson_null;
get_bin_data = get_bin_data;
get_utc_date = get_utc_date;
}
4 changes: 3 additions & 1 deletion lib/resty/mongol/colmt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ function colmethods:query(query, returnfields, numberToSkip, numberToReturn, opt
+ 2^7*( options.Partial and 1 or 0 )
end

query = to_bson(query)
if type(query) ~= "string" then
query = to_bson(query)
end
if returnfields then
returnfields = to_bson(returnfields)
else
Expand Down
2 changes: 2 additions & 0 deletions lib/resty/mongol/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ local connmethods = { }
local connmt = { __index = connmethods }

local dbmt = require ( mod_name .. ".dbmt" )
local bson = require ( mod_name .. ".bson" )
null = bson.bson_null

function connmethods:ismaster()
local db = self:new_db_handle("admin")
Expand Down