1

だから私のコードは次のとおりです。

FindIterable<Document> findIterable = collection.find().skip(20).limit(10);
MongoCursor<Document> cursor = findIterable.iterator();
while (cursor.hasNext()) {
    Document doc = cursor.next();
    // My stuff with documents here
}
cursor.close(); // in finally block

ここで、とtotal countの前のドキュメントの を知りたいと思います。skiplimit

まったく同じ質問に対する回答がありますが、私が持っているものmongo-java-driver v3.1.0と使用する API が異なります。FindIterableクラスとcount()MongoCursorクラスsize()の両方にメソッドはありませ。ありがとう!

アップデート

collection.count@Philippが言ったように、唯一の回避策はmongodbへの別の呼び出しを行うことのようです

4

1 に答える 1