title: How to return a string from a lambda function?
body: <p>I call the function myFunction() and like to get the source._id returned unfortunately the following code does not work. The source._id is fill and ok but how can I return it complete back? As something like:</p>
  
  <pre><code>var newId = myFunction();
  </code></pre>
  
  <p>The query and the save are mongoose promises.</p>
  
  <pre><code>        var myFunction = () =&gt; {
              var query = MyModel.findOne({ user: userId, name: name.name });
  
              query.exec((err, doc) =&gt; {
                  if (err) {
                      reject (err);
                  } else {
                      if (doc != null) {
                          var msg = "Error Msg here";
                          reject(new ValidationError(msg));
                      } else {
                          var source = new MyModel();
                          source.someUserProp  = userId;
                          source.save((err, doc) =&gt; {
                              if (err) {
                                  throw (err)
                              }
                              else { 
                                  return (source._id);
                              }
                          });
                      }
                  }
              })
          };
  </code></pre>