使用mongdb erlang驱动程序查询返回错误的结果? [英] Query return wrong result using mongdb erlang driver?

查看:87
本文介绍了使用mongdb erlang驱动程序查询返回错误的结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试

Query = {country,<US>>},
mongo:find(Col,{'$查询',查询'$ orderby',{last_seen,-1}},投影机0,15),

Query = {country, <<"US">>}, mongo:find(Col, { '$query', Query, '$orderby', {last_seen, -1} }, Projector, 0, 15),

返回的游标不限于批量大小15再说了它将以光标返回所有结果。但是,如果我将其更改为

The cursor returned is not limited to batch size 15 any more. It will return all the results in cursor. However, if I change it to

mongo:find(Col,Query,Projector,0,15),

mongo:find(Col, Query, Projector, 0, 15),

它将返回15个大小的光标。

It will return the cursor with 15 in size.

这是一个错误还是我做错了?

Is this a bug or I did anything wrong?

推荐答案

它适用于我下面的例子

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.

这篇关于使用mongdb erlang驱动程序查询返回错误的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆