当我尝试
时查询= {country,<<“US”>>}, mongo:find(Col,{'$ query',Query,'$ orderby',{last_seen,-1}},投影仪,0,15),
返回的光标不再限于批量大小15。它将返回光标中的所有结果。但是,如果我将其更改为
mongo:find(Col,Query,Projector,0,15),
它将返回15个大小的光标。
这是一个错误还是我做错了什么?
答案 0 :(得分:2)
以下示例适用于我
run () ->
application:start (mongodb),
{ok, Conn} = mongo:connect (localhost),
{ok, Docs} = mongo:do (safe, master, Conn, test, fun() ->
mongo:delete (foo, {}),
mongo:insert_all (foo, [{x,1}, {x,2}, {x,3}, {x,0}, {x,-1}]),
Cur = mongo:find (foo, {'$query', {}, '$orderby', {x,1}}, {'_id',0}, 0, 3),
mongo:rest (Cur) end),
mongo:disconnect (Conn),
[{x,-1}, {x,0}, {x,1}] = Docs.