title: assigning mongoose result feild value to vriable in express
body: <p>i am trying to assign value of a feild from momgoose to a variable which would be used as value to another feild in another schema which is as follows.</p>
  
  <pre><code>function getNextSequence() {
      var x = null
      relcounter.findOne({"name":"cabi"},'seq',  function (err, configs) {
      x=configs.seq
       console.log("##"+x)
       })
       console.log(x)
  
  }
  </code></pre>
  
  <p>X is coming out to be null 
  Also i need this value of x to add to another feild which is as follows </p>
  
  <pre><code>relconf.update( 
                     {name:"css"},
                      { $push: { relations: {id:getNextSequence(),name:req.body.name,divId:"name_div"} } }
  </code></pre>
  
  <p><strong>Basically ineed the function getNextsequence to return the value of seq feild and assign to id feild</strong>
  can anyone suggest proper code and reason for null value for getNextSequence()</p>