title: In MongoDb Morphia how to delete or replace an array object
body: <p>I can only find how to remove first, last or selected object<br>
  but i need to delete the entire array.    </p>
  
  <p>In Morphia i have this below <code>Document</code> <code>FriendList</code>.    </p>
  
  <p>In the <code>Document</code> you see the <code>array</code> <code>friendList</code>.<br>
  I need to update this <code>array</code> with new <code>"friends"</code>.   </p>
  
  <p>What need to happen is i must delete all entries in the <code>friendList</code><br>
  before populating it with new friends.   </p>
  
  <p>Was thinking i could delete it and then simply insert a new<br>
  <code>array</code>  <code>friendList</code> containing <code>"friends"</code>.</p>
  
  <p>How can i delete the <code>array</code>?</p>
  
  <p>Maybe im all wrong about how to do this since i cannot find a solution..</p>
  
  <pre><code>@Entity
  public class FriendList {
  
      @Id private ObjectId id;
  
      public Date lastAccessedDate;
  
      @Indexed(name="uuid", unique=true,dropDups=true)  
      private String uuid;
  
  
      List&lt;String&gt; friendList;
  
      public void setUuid(String uuid) {
          this.uuid = uuid;
      }
  
      public List&lt;String&gt; getFriendList() {
          return friendList;
      }
  
      public void insertFriend(String friend) {
          this.friendList.add(friend);
      }
  
  }
  </code></pre>
  
  <p>from the <a href="http://code.google.com/p/morphia/wiki/Updating" rel="nofollow">documentation</a> I try this in various combinations with no luck:   </p>
  
  <pre><code>mongo.createUpdateOperations(FriendList.class).removeAll("friendList", "??");
  </code></pre>