我想滚动浏览mongodb REST响应的所有页面。
ubuntu@ubuntu:/etc$ curl http://localhost:28017/bb/feeds/?limit=1
没有偏移,我得到正确的结果
{
"offset" : 0,
"rows": [
{ "_id" : { "$oid" : "57254bd21d41c82413afed60" }, "variety" : "Other", "modal_price" : "2150", "commodity" : "Rice", "max_price" : "2200", "state" : "West Bengal", "min_price" : "2100", "district" : "Uttar Dinajpur", "timestamp" : "1462026632", "market" : "Islampur", "id" : "87200341", "arrival_date" : "30/04/2016" }
],
"total_rows" : 1 ,
"query" : {} ,
"millis" : 0
}
但当我通过偏移量=2时,我仍然得到相同的结果
ubuntu@ubuntu:/etc$ curl http://localhost:28017/bb/feeds/?limit=1&offset=2
{
"offset" : 0,
"rows": [
{ "_id" : { "$oid" : "57254bd21d41c82413afed60" }, "variety" : "Other", "modal_price" : "2150", "commodity" : "Rice", "max_price" : "2200", "state" : "West Bengal", "min_price" : "2100", "district" : "Uttar Dinajpur", "timestamp" : "1462026632", "market" : "Islampur", "id" : "87200341", "arrival_date" : "30/04/2016" }
],
"total_rows" : 1 ,
"query" : {} ,
"millis" : 0
}
您需要传递的URL参数实际上是skip
,而不是offset
:
curl http://localhost:28017/bb/feeds/?limit=1&skip=2
其在JSON输出中被指示为CCD_ 3值。
注意:MongoDB中内置的REST接口在功能和安全性方面非常有限,在MongoDB 3.2中不推荐使用。我强烈建议研究一种替代的(并积极维护的)REST API。有关起点,请参阅MongoDB手册中的HTTP接口。