title: How to do dirty check between old and new model object and insertOrUpdate if any change is there?
body: <p>Thanks in advance.</p>
  
  <p>I have scenario where i wanted to check the data difference between existing and new realm model object.</p>
  
  <p>Example </p>
  
  <pre><code>public class PostModel extends RealmObject {
  
      @Required
      @PrimaryKey
      @Index
      private String postId;
      private String message;
  
  }
  </code></pre>
  
  <p>Let say we have two objects</p>
  
  <p>Old </p>
  
  <pre><code>PostModel old = new PostModel("one", "Welcome");
  realm.copyToRealm(old);
  </code></pre>
  
  <p>New Object </p>
  
  <pre><code>PostModel newOne = new PostModel("one", "Welcome to World");
  </code></pre>
  
  <p>before updating the old object with newOne should check data change, if change is there then should insert in the realm, like below</p>
  
  <pre><code>realm.dirtyCheckAndUpdate(old, newOne);
  </code></pre>
  
  <p>//underlying it should do below</p>
  
  <ol>
  <li>Getting the record with id "one"</li>
  <li>Check the difference between db record and new record (!old.message.equalsIgnore(newOne.message)).</li>
  <li>if change is there then copyToRealmOrUpdate() should happen.</li>
  </ol>
  
  <p>I just gave an example, i need to to this for complex RealmModel with relationship.</p>