Assume that I have a collection named "students" below:
- collection
students
has 3 fields:- name
- age
- status (0: passed, 1: failed, -1: not tested)
('status' field describles the student passed or failed or Notyet tested)
- The collection
students
has 1000 documents with different 'status' - Now I want to get the count of students who [passed/failed/not tested] the exam
- And whenever 'status' of a student is updated 0/1/-1 then I will have to re-count.
How can I solve this? I shouldn't query all data for everytime update because it will cause high cost. NOTICE that, I want to count base on the 'status' field.