mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
feat: add mongo safe batch delete (#1577)
This commit is contained in:
@@ -186,6 +186,32 @@ local function test_safe_batch_insert()
|
||||
assert(length == ret:count(), "test safe batch insert failed")
|
||||
end
|
||||
|
||||
local function test_safe_batch_delete()
|
||||
local ok, err, ret
|
||||
local c = _create_client()
|
||||
local db = c[db_name]
|
||||
|
||||
db.testcoll:drop()
|
||||
|
||||
local docs, length = {}, 10
|
||||
for i = 1, length do
|
||||
table.insert(docs, {test_key = i})
|
||||
end
|
||||
|
||||
db.testcoll:safe_batch_insert(docs)
|
||||
|
||||
docs = {}
|
||||
local del_num = 5
|
||||
for i = 1, del_num do
|
||||
table.insert(docs, {test_key = i})
|
||||
end
|
||||
|
||||
db.testcoll:safe_batch_delete(docs)
|
||||
|
||||
local ret = db.testcoll:find()
|
||||
assert(length == ret:count(), "test safe batch delete failed")
|
||||
end
|
||||
|
||||
skynet.start(function()
|
||||
if username then
|
||||
print("Test auth")
|
||||
@@ -203,5 +229,7 @@ skynet.start(function()
|
||||
test_expire_index()
|
||||
print("test safe batch insert")
|
||||
test_safe_batch_insert()
|
||||
print("test safe batch delete")
|
||||
test_safe_batch_delete()
|
||||
print("mongodb test finish.");
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user