Jelajahi Sumber

Step 8.5: Update getMeteorData to return incompleteCount.

Frederic G. MARAND 9 tahun lalu
induk
melakukan
1c3eaddd30
1 mengubah file dengan 7 tambahan dan 2 penghapusan
  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);