title: Mongoose update ref objects?
body: <p><br>Sorry for my bad English.<br>
  I use node.js + express.js + mongoose.js
  i have this schema in mongoose for groups:<br></p>
  
  <pre><code>var groupSchema = new mongoose.Schema({
      name: String,
      users: [{type: mongoose.Schema.ObjectId, ref: 'User'}],
      posts: [{type: mongoose.Schema.ObjectId, ref: 'Post'}]
  });
  </code></pre>
  
  <p>and this schema to users:</p>
  
  <pre><code>var userSchema = new mongoose.Schema({
    login:    { type: String, unique: true, lowercase: true },
    password: String,
    unread:   [{type: mongoose.Schema.ObjectId, ref: 'Post'}]      
  });
  </code></pre>
  
  <p>Group has list of users, related to this group, and list of post, related to this group.<br>
  What i want to realize:<br>
  <code>Group1</code> has users <code>Mike</code>, <code>John</code> and <code>Jane</code>;<br>
  When user <code>Mike</code> create a new post: <br>1)I find current group and select users,related to this group (<code>Group1</code> and users <code>Mike</code>, <code>John</code> and <code>Jane</code>);<br><br> 2)To users <code>John</code> and <code>Jane</code> i must set the created post in <code>unread</code> field.
  (make this to know, which post user has not yet read).<br>
  Is it correct? If yes, how can i update this unread field in ref documents? 
  <br>
  I'm tried to do this:<br>
  At example: url of the group: <code>http://localhost:3000/group/first</code></p>
  
  <pre><code>  app.get('/group/:name', groups.getGroupPage);
  
    app.post('/group/:name', posts.postCreate);
  </code></pre>
  
  <p>Posts.js</p>
  
  <pre><code>var Group = require('../models/group');
  var User = require('../models/user');
  var Post = require('../models/post');
  
          exports.postCreate = function(req, res) {
           var post = new Post({
              title: req.body.p_title,
              content: req.body.p_content,
              author: req.user
           });
           Group
                    .update({ name: req.params.name }, {upsert:true}, { "$push": { "users.$.unread": post._id } })
                    .populate('users')
                    .exec(function(err,group) {
                         if (err) res.json(err)
                         console.log(group);
                      }
                    );
          }
  </code></pre>
  
  <p>Thank's for any help.</p>