title: Updating object inside an array of objects
body: <p>I have an object with an array of objects like that:</p>
  
  <pre><code>//restMenuType({_id: 'abcde', hasItems: [{itemId: 'a', sortId: 1}, {itemId: 'b', sortId: 2}]})
  </code></pre>
  
  <p>I am trying to replace the sortId key on both objects:</p>
  
  <pre><code>'replaceItemsPositionUp': function(typeId, prevId, curId, prevSortId, curSortId){
          RestMenuTypes.update({
              _id: typeId,
              hasItems: {$elemMatch: {itemId: curId}}},
              {$set: {'hasItems.sortId': prevSortId}}
          );
          RestMenuTypes.update({
                  _id: typeId,
                  hasItems: {$elemMatch: {itemId: prevId}}},
              {$set: {'hasItems.sortId': curSortId}}
          );
  
      }
  </code></pre>
  
  <p>What is thee right way to do it?
  Thanks.</p>