1
目的:私は、ユーザーが1つのインデックスページで最大値と最小値でレンタルを並べ替える方法を見つけようとしています。Mongodbのデータを価格で並べ替え
私の問題は、lowpriceとhighprice専用の2つの別々のページを作成する方法を理解する唯一の方法です。私は1つの主要な索引しか持たない。あなたはおそらく気づいたよう
は、以下に示すpricelowページには、高価格
app.get("/pricelow", function(req, res){
Listings.find({}).sort({price: 1}).exec(function(err, allListings){
if(err){
console.log(err);
} else {
res.render("pricelow",{listings:allListings});
}
})
});
//以下に示しpricehighページは低価格
app.get("/pricehigh", function(req, res){
Listings.find({}).sort({price: -1}).exec(function(err, allListings){
if(err){
console.log(err);
} else {
res.render("pricehigh",{listings:allListings});
}
})
});
本当に素晴らしい答えです。助けてくれてありがとう。 – AndrewLeonardi