title: passing data between server and client (node.js + mongodb)
body: <p>I'm working with node.js express and mongodb, I have a input data from client, I need to pass the data to server look for its property and send to the client in another page.</p>
  
  <p>Now I have problem with    <code>req.body.age</code> that suppossed to get the data from client's input and use <code>find()</code> to get its appropriate property.</p>
  
  <p><strong>Server side code:</strong></p>
  
  <p>functions are routed in another .js file</p>
  
  <pre><code>exports.find_user = function(req, res) {
      res.render('find_user.jade');
  };
  
  
  exports.user = function(req, res){
      member = new memberModel();
      member.desc.age = req.body.age; //problem
      console.log(req.body.age);  //undefined 
      memberModel.find({desc: {age: '7'}}, function(err, docs){
          res.render('user.jade', { members: docs });
      console.log(docs);
  });
  };
  </code></pre>
  
  <p><code>memberModel.find({desc: {age: '7'}}</code> just hardcode picking up user with age 7 (works)</p>
  
  <p><strong>client side code (jade):</strong></p>
  
  <p>page for data input:</p>
  
  <p>find_user.jade</p>
  
  <pre><code>form(action='/', method='post')
      fieldset
          lable(for="age") Find user by age: 
              input(type="text", size="30", name="age", required="required")
              input(type='button', value='Find', onclick='location.href=\'find_user/user/\'')
  </code></pre>
  
  <p>page for data output with its property:</p>
  
  <p>user.jade</p>
  
  <pre><code>        tr
              th Name
              th Age
      tbody
      - members.forEach(function(member){
          tr
              td= member['name']
              td= member['desc']
       - });
  </code></pre>