Przeglądaj źródła

Commit 10.3: Replace insert with addTask method.

Frederic G. MARAND 8 lat temu
rodzic
commit
0b2ce55796
1 zmienionych plików z 3 dodań i 7 usunięć
  1. 3 7
      simple-todos.js

+ 3 - 7
simple-todos.js

@@ -29,12 +29,8 @@ if (Meteor.isClient) {
 
       var text = event.target.text.value;
 
-      Tasks.insert({
-        text: text,
-        createdAt: new Date(),    // current time
-        owner: Meteor.userId(),   // _id of logged-in user
-        username: Meteor.user().username
-      });
+      // Insert a task into the collection.
+      Meteor.call('addTask', text);
 
       // Clear form
       event.target.text.value = "";
@@ -75,7 +71,7 @@ Meteor.methods({
       text: text,
       createdAt: new Date(),
       owner: Meteor.userId(),
-      username: Meteor.user().name
+      username: Meteor.user().username
     };
     Tasks.insert(task);
   },