简体   繁体   English

couchdb4j遍历数据库

[英]couchdb4j traverse the database

First, I'm using couchdb4j. 首先,我正在使用couchdb4j。 Normally if we want to traverse the couchdb, we put the whole database into a view by using the 通常,如果我们想遍历couchdb,可以通过使用

ViewResults results = db.getAllDocuments() ViewResults结果= db.getAllDocuments()

But my database is about 1 Gb with about 110000 rows, so it is too big to put the whole database into the ViewResults List. 但是我的数据库大约有1 Gb,大约有110000行,因此太大了,无法将整个数据库放入ViewResults列表中。 My document id is default(that's my bad, I should have set id numbers like 1,2,3...). 我的文档ID是默认的(这很不好,我应该设置ID号,例如1,2,3 ...)。 So, I'm just wondering is there a way to traverse the whole documents without putting them all into a view? 因此,我只是想知道是否有一种方法可以遍历整个文档而不将其全部放入视图中? Or, is there a way that I can export the whole database into a csv file? 或者,是否可以将整个数据库导出到一个csv文件中? Thanks. 谢谢。

So, I'm just wondering is there a way to traverse the whole documents without putting them all into a view? 因此,我只是想知道是否有一种方法可以遍历整个文档而不将其全部放入视图中?

Yes. 是。 You can paginate the results of your requests by using the query parameters ?skip=...&limit=... 您可以使用查询参数?skip=...&limit=...对请求的结果进行分页?skip=...&limit=...

You will request batches of the primary index /_all_docs . 您将请求批处理主索引/_all_docs Every response inherits the informations you need to request the next batch. 每个响应都继承您请求下一批所需的信息。 Here is an example response: 这是一个示例响应:

{
  "total_rows":12345,
  "offset":500, // the current position
  "rows" :[{...}]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM