"q=word/s=0/t=5" というルートを持つサーバーを使用しています。ここで、q はクエリ文字列、s は開始ドキュメント、t は制限です。
したがって、最初のリクエストでは、q に基づいてドキュメントをクエリし、取得した結果の 0 から 5 までの結果を表示します。
次のリクエストでは、q=word/s=6/t=5 とします。ドキュメント番号 6 から 10 までのドキュメントを表示する必要があります。
mongoでそれを達成できる方法はありますか。私はmongojsでnodejsを使用しています。どんな助けでも大歓迎です。
var words = req.params.q.split(" ");
var patterns = [];
// Create case insensitve patterns for each word
words.forEach(function(item){
patterns.push(caseInsensitive(item));
});
db.collection('mycollection', function(err, collection) {
collection.find({index : {$all: patterns }}).skip((s-1)*t).limit(t).toArray(function(err, items) {
if( err || !items) {
res.header("Access-Control-Allow-Origin", "*");
console.log('nothing');
res.send([]);
} else {
res.header("Access-Control-Allow-Origin", "*");
console.log(items);
res.send(items);
}
});