Synchronously collection.insert in a

This code is trying to add a document to a collection by making a, But I need to wait for the results of ActiveTask.insert(doc); in the server code before the next line gets executed by the compiler because it runs another code which depends of the value being inserted in the collection ActiveTask.

Is this possible and how? Thanks

  'click .menuItem': function () {
    var menuShortName = this.menuShortName;'addAction', {'action': menuShortName});


    addAction: function (doc) {
        doc.createdAt = new Date();

What is that next line? When we know what you want to achieve, we can suggest the optimal way to do it.

But in most cases, good enough way is to use’s callback to grab the result from the Method and put the code you wanted to execute later into the callback. The alternative is to keep it outside of the callback, but execute it when a particular flag from the callback is set.