Skip to content

Commit

Permalink
临时提交修改
Browse files Browse the repository at this point in the history
  • Loading branch information
xiyoo0812 committed Nov 2, 2023
1 parent 55a8a4d commit e30fdcc
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions script/driver/mongo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ function MongoDB:drop_collection(co_name)
end

-- 参数说明
-- indexes: {{key={open_id, platform_id}, name="open_id-platform_id", unique=true} }
-- indexes: {{key={open_id=1, platform_id=1}, name="open_id-platform_id", unique=true} }
-- indexes: {{key={open_id=1}, name="open_id", unique=true} }
-- indexes: {{key={open_id,1,platform_id,1}, name="open_id-platform_id", unique=true} }
function MongoDB:create_indexes(co_name, indexes)
for _, index in pairs(indexes) do
index.key = self:format_pairs(index.key)
Expand Down Expand Up @@ -389,19 +389,14 @@ function MongoDB:format_pairs(args, doc)
if type(next(args)) == "string" then
return args
end
local array = {}
for _, key in pairs(args) do
array[#array + 1] = key
array[#array + 1] = 1
end
if doc then
array[#array + 1] = doc
args[#args + 1] = doc
end
return bsonpairs(tunpack(array))
return bsonpairs(tunpack(args))
end

-- 参数说明
--sort: {k1=1,k2=1} / {k1,k2,k3}
--sort: {k1=1} / {k1,1,k2,-1,k3,-1}
function MongoDB:find(co_name, query, projection, sortor, limit, skip)
local fsortor = self:format_pairs(sortor, self.sort_doc)
local succ, reply = self:runCommand("find", co_name, "filter", query, "projection", projection, "sort", fsortor, "limit", limit, "skip", skip)
Expand Down

0 comments on commit e30fdcc

Please sign in to comment.