mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
@@ -494,11 +494,12 @@ function mongo_collection:raw_safe_delete(delete)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function mongo_collection:findOne(query, projection)
|
function mongo_collection:findOne(query, projection)
|
||||||
local cursor = self:find(query, projection)
|
local r = self.database:runCommand("find", self.name, "filter", query and bson_encode(query) or empty_bson,
|
||||||
if cursor:hasNext() then
|
"limit", 1, "projection", projection and bson_encode(projection) or empty_bson)
|
||||||
return cursor:next()
|
if r.ok ~= 1 then
|
||||||
|
error(r.errmsg or "Reply from mongod error")
|
||||||
end
|
end
|
||||||
return nil
|
return r.cursor.firstBatch[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
function mongo_collection:find(query, projection)
|
function mongo_collection:find(query, projection)
|
||||||
|
|||||||
Reference in New Issue
Block a user