mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
feat: add mongo safe batch delete (#1577)
This commit is contained in:
@@ -423,6 +423,18 @@ function mongo_collection:safe_delete(selector, single)
|
||||
return werror(r)
|
||||
end
|
||||
|
||||
function mongo_collection:safe_batch_delete(selectors, single)
|
||||
local delete_tb = {}
|
||||
for i = 1, #selectors do
|
||||
delete_tb[i] = bson_encode({
|
||||
q = selectors[i],
|
||||
limit = single and 1 or 0,
|
||||
})
|
||||
end
|
||||
local r = self.database:runCommand("delete", self.name, "deletes", delete_tb)
|
||||
return werror(r)
|
||||
end
|
||||
|
||||
function mongo_collection:findOne(query, selector)
|
||||
local conn = self.connection
|
||||
local request_id = conn:genId()
|
||||
|
||||
Reference in New Issue
Block a user