2017-08-02 4 views

答えて

0

あなたはそうのような特定の月に作成した請求書のためのあなたのコレクションを検索することができます

var taxTotal = 0; 
var results = cursor.forEach(function(doc) { 
    //Adds the tax field of each document to the total 
    taxTotal += doc.tax; 
}); 

より:

var start = new Date(year, month, day); 
var end = new Date(year, month, day); 

//Invoices with a 'date' field between the 'start' and 'end' dates 
var cursor = CollectionName.find({ date : { $gte : start, $lt: end }); 

その後、税フィールドの合計を見つけることができますカーソルのforEachメソッドの情報here

+0

ありがとう!これは私をたくさん助けます! –

関連する問題