我在MongoDB中如何計算的標準記錄和的NodeJS MongoDB的
{
"_id" : ObjectId("585e34c50ab3cd228a8d6828"),
"fullname" : "Name1",
"status" : "INACTIVE",
"createdDate" : ISODate("2016-12-24T08:41:41.225Z"),
"updatedDate" : ISODate("2016-12-24T08:41:41.225Z")
},
{
"_id" : ObjectId("525e34c50ab3cd228a8d6828"),
"fullname" : "Name2",
"status" : "ACTIVE",
"createdDate" : ISODate("2016-12-24T08:41:41.225Z"),
"updatedDate" : ISODate("2016-12-24T08:41:41.225Z")
}
以下JSON對象和下方的返回代碼所有JSON對象的所有計數。
db.collection(col).count(function (err, res) {
if (err)
throw err;
db.close();
});
但我只需要計算「ACTIVE」狀態結果。怎麼做?