-- 顯式 $and
db.coll.find({$and: [{$where: '(1386813645 - this.last_active_time > 300)'}, {status: "online"}]})
-- 隱式 AND (多鍵值並列即為 AND)
db.coll.find({$where: '(1386813645 - this.last_active_time > 300)', status: "online"})
兩者等價,隱式寫法更簡潔。MongoDB 2.0+ 引入顯式 $and 以支援同一欄位多條件或複雜邏輯組合。
MongoDB Manual: $and Operator