title: TypeError: Cannot use 'in' operator to search for '_id' in male
body: <p>Hi i am having issue with using the new versions of node.js
  Earlier i used a code like this</p>
  
  <pre><code> label(for='user_sex') Sex:
   select(id='user_sex', name='user[sex]')
     option(id='user_male',value=user.sex,selected=1)='male'
     option(id='user_female',value=user.sex)='female'
  </code></pre>
  
  <p>And code in app.js</p>
  
  <pre><code> var user = new User(req.body.user);
   -- other code
   var sex = new User(req.body.user.sex);
   User.find({}, function(err, users) {
   for(var i = 0;i&lt; users.length;i++) {
      if(users[i].email == email) {
         useremail = users[i].email;
      }
   }
   if(!useremail) {
      user.save(function(err) {
        if (err) return userSaveFailed();
        req.flash('info', 'Your account has been created');
        emails.sendWelcome(user);
  
        switch (req.params.format) {
          case 'json':
            res.send(user.toObject());
          break;
  
          default:
            req.session.user_id = user.id;
            res.redirect('/userinfo');
        }
      });
   }
  </code></pre>
  
  <p>The complete error log is as follows:</p>
  
  <pre><code>500 TypeError: Cannot use 'in' operator to search for '_id' in male
  
  at model.Document.$__buildDoc (C:\SocialNetwork\node_modules\mongoose\lib\document.js:159:27)
  at model.Document (C:\SocialNetwork\node_modules\mongoose\lib\document.js:58:20)
  at model.Model (C:\SocialNetwork\node_modules\mongoose\lib\model.js:38:12)
  at new model (C:\SocialNetwork\node_modules\mongoose\lib\model.js:2092:11)
  at C:\SocialNetwork\app.js:1033:13
  at callbacks (C:\SocialNetwork\node_modules\express\lib\router\index.js:272:11)
  at param (C:\SocialNetwork\node_modules\express\lib\router\index.js:246:11)
  at param (C:\SocialNetwork\node_modules\express\lib\router\index.js:243:11)
  at pass (C:\SocialNetwork\node_modules\express\lib\router\index.js:253:5)
  at Router._dispatch (C:\SocialNetwork\node_modules\express\lib\router\index.js:280:5)
  </code></pre>
  
  <p>The problem seems with connect-form which i know is deprecated now, so i am using formidable now. Can anybody help me out to solve this error</p>