فهرست منبع

W3.5: store the result of a method call.

Frederic G. MARAND 9 سال پیش
والد
کامیت
6ffdbc0ba5
1فایلهای تغییر یافته به همراه8 افزوده شده و 2 حذف شده
  1. 8 2
      textcircle.js

+ 8 - 2
textcircle.js

@@ -61,7 +61,12 @@ if (Meteor.isClient) {
         alert("You need to login first.");
       }
       else {
-        Meteor.call("addDoc");
+        Meteor.call("addDoc", function (err, res) {
+          if (!err) {
+            console.log("addDoc res", res);
+            Session.set("docid", res);
+          }
+        });
       }
     }
   });
@@ -90,7 +95,8 @@ Meteor.methods({
         createdOn: new Date(),
         title: "my new doc"
       };
-      Documents.insert(doc);
+      const docid = Documents.insert(doc);
+      return docid;
     }
   },