比較的単純なシナリオ:
(タイプの)プロパティを持つこのVoucher
オブジェクトがあります。1 人のユーザーのすべてのバウチャーの値の合計を取得したいと考えています。空の配列を返す私の現在の戦略は次のとおりです。user
ObjectId
Voucher.aggregate [
{ $match : { user : new ObjectId(user_id), expires : { $gt : new Date() } } }
{ $group : { _id : null, sum : { $sum : '$value' } } }
], (err, result)->
console.log err
console.log result
IDの一致を削除しuser
、フィールドを離れるとexpires
結果が返されます。それで、問題は、上の一致の何が問題なのuser
ですか?