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