Browse Source

Step 8.5: Update getMeteorData to return incompleteCount.

Frederic G. MARAND 8 years ago
parent
commit
1c3eaddd30
1 changed files with 7 additions and 2 deletions
  1. 7 2
      App.jsx

+ 7 - 2
App.jsx

@@ -15,12 +15,17 @@ App = React.createClass({
   getMeteorData() {
     let query = {};
 
+    const uncheckedQuery = { checked: { $ne: true} };
+
     if (this.state.hideCompleted) {
       // If hideCompleted is checked, filter tasks.
-      query = { checked: { $ne: true} };
+      query = uncheckedQuery;
     }
     let result = {
-      tasks: Tasks.find(query, { sort: { createdAt: -1 }}).fetch()
+      tasks: Tasks.find(query, { sort: { createdAt: -1 }}).fetch(),
+      // Since we already have the data in the client-side Minimongo collection,
+      // adding this extra count doesn't involve asking the server for anything.
+      incompleteCount: Tasks.find(uncheckedQuery).count()
     };
 
     // Meteor._debug("result", result);