title: mongodb aggregation framework - Fetch first document's field of the nested array
body: <p>Consider the following is my document stored in collection <code>Users</code></p>
  
  <pre><code>{
    _id : "User1",
    joined : ISODate("2011-03-02"),
    likes : {
             sublikes: [
                        {WebsiteID:'001': WebsiteName: 'ABCD'},
                        {WebsiteID:'002': WebsiteName: '2BC2'},
                        {WebsiteID:'003': WebsiteName: '3BC3'},
                        //........... 
                        //........... 
                        {WebsiteID:'999999': WebsiteName: 'SOME_NAME'}
                       ]
            }
  }
  </code></pre>
  
  <p>Now using mongodb aggregation framework I need to fetch that</p>
  
  <pre><code>collection.aggregate([
                          { $project: {
                              _id: 1,
                              "UserID": "$_id", 
                              "WebsiteName": "$likes.sublikes[0]['WebsiteName']"
                          }
                          },
                           { $match: { _id: 'User1'} }
                        ], function (err, doc) {
   ///Not able to get the WebsiteName: 'ABCD'
  });
  </code></pre>
  
  <p>If I use <code>$unwind</code> the document becomes bulk (specifically in the above case), So I don't want to unwind it for getting only first item in an array (irrespective of others)</p>
  
  <p>Can anyone give me hints on how to access is and rename that field?
  <hr>
  <strong>Update</strong> 1: Even I tried to project with <code>"WebsiteName": "$likes.sublikes.0.WebsiteName"</code>. Didn't work :-(</p>
  
  <p><strong>Update</strong> 2: Open issue - <a href="https://jira.mongodb.org/browse/SERVER-4589">https://jira.mongodb.org/browse/SERVER-4589</a></p>
  
  <p>As of now <code>$at</code> does not work. Throws an error:</p>
  
  <pre><code>{ [MongoError: exception: invalid operator '$at']
    name: 'MongoError',
    errmsg: 'exception: invalid operator \'$at\'',
    code: 15999,
    ok: 0 }
  </code></pre>
  
  <p>Till then using 
  <code>$unwind</code><br></p>
  
  <pre><code>// Array Remove - By John Resig (MIT Licensed)
  Array.prototype.remove = function(from, to) {
    var rest = this.slice((to || from) + 1 || this.length);
    this.length = from &lt; 0 ? this.length + from : from;
    return this.push.apply(this, rest);
  };
  </code></pre>