Skip to content

Commit b7aa63c

Browse files
committed
fixed #101
1 parent ea780d9 commit b7aa63c

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

lib/mongo.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ defmodule Mongo do
671671

672672
cmd = filter_nils(cmd)
673673

674-
drop = ~w(limit hint single_batch read_concern max min collation return_key show_record_id tailable no_cursor_timeout await_data batch_size projection comment max_time skip sort)a
674+
drop = ~w(limit hint single_batch read_concern max min collation return_key show_record_id tailable no_cursor_timeout await_data projection comment skip sort)a
675675
opts = Keyword.drop(opts, drop)
676676
try do
677677
get_stream(topology_pid, cmd, opts)

test/mongo/batch_size_text.exs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
defmodule Mongo.BatchSizeTest do
2+
3+
require Logger
4+
5+
use CollectionCase
6+
7+
test "find, using :batch_size of 100 options", %{pid: top, catcher: catcher} do
8+
9+
coll = unique_collection()
10+
n = 10_000
11+
Mongo.delete_many(top, coll, %{})
12+
13+
Enum.each(1..n, fn i ->
14+
Mongo.insert_one(top, coll, %{index: i}, [w: 0])
15+
end)
16+
17+
assert {:ok, n} == Mongo.count(top, coll, %{})
18+
19+
assert n == top
20+
|> Mongo.find(coll, %{}, batch_size: 100)
21+
|> Enum.to_list()
22+
|> Enum.count()
23+
24+
get_mores = catcher
25+
|> EventCatcher.succeeded_events()
26+
|> Enum.map(fn event -> event.command_name end)
27+
|> Enum.filter(fn command_name -> command_name == :getMore end)
28+
|> Enum.count()
29+
30+
assert 100 == get_mores
31+
end
32+
end

0 commit comments

Comments
 (0)