title: AngularFire5 — Reference.update failed: First argument contains a function in property
body: <p>
  I'm trying to save changes to an existing node in my Firebase DB, but I'm getting this error here:</p>
  
  <blockquote>
    <p>Reference.update failed: First argument contains a function in property 'matatu-list.-L-RMcqjnladFM5-V80b.payload.node_.children_.comparator_' with contents = function NAME_COMPARATOR(left, right) {
        return util_1.nameCompare(left, right);
    }</p>
  </blockquote>
  
  <p>I want to edit an item basing on its respective key (which is passed from another page through <code>navParams</code>).  </p>
  
  <p>
  Here is the interface I used to structure the DB:</p>
  
  <p><code>interface.ts</code></p>
  
  <pre><code>export interface Matatu {
      $key?: string;
      matNumberPlate: string;
      matSacco: string;
      matDriver: string;
      matAccessCode: string;
      matStatus: string;
      matTracker: string;
      matLocation: string;
  
      //Optionals
      payload?:any;
      key?:any;
  
  }
  </code></pre>
  
  <p>The <code>.ts</code> and <code>.html</code> code that's meant to update the record:</p>
  
  <p><code>.ts</code></p>
  
  <pre><code>import { Component } from '@angular/core';
  import { IonicPage, NavController, NavParams } from 'ionic-angular';
  import { AngularFireObject, AngularFireDatabase } from 'angularfire2/database';
  import { Matatu } from '../../models/matatu/matatu.interface';
  import { Subscription } from 'rxjs/Subscription';
  
  
  @IonicPage()
  @Component({
    selector: 'page-edit-ma3',
    templateUrl: 'edit-ma3.html',
  })
  export class EditMa3Page {
  
    matatuRef$: AngularFireObject&lt;Matatu&gt;;
    matatuAsync$: any;
    matatu = {} as Matatu;
    sub: Subscription;
  
    constructor(public navCtrl: NavController, public navParams: NavParams, private database: AngularFireDatabase) {
  
      const matKey = this.navParams.get('matKey');
      this.matatuRef$ = this.database.object(`matatu-list/${matKey}`);
      this.matatuAsync$ = this.matatuRef$.snapshotChanges();
      //console.log(matKey);
  
      this.sub = this.matatuAsync$.subscribe(
        matatu =&gt; this.matatu = matatu
      )
    }
  
    editMatatu(matatu : Matatu){
      this.matatuRef$.update(matatu);
  
      this.navCtrl.pop();
    }
  
    ionViewWillLeave(){
      this.sub.unsubscribe();
    }
  
  }
  </code></pre>
  
  <p><code>.html</code></p>
  
  <pre><code>&lt;ion-content&gt;
    &lt;ion-list&gt;
      &lt;ion-list-header&gt;
        Matatu Details 
      &lt;/ion-list-header&gt;
  
      &lt;ion-item&gt;
          &lt;ion-label&gt;Sacco&lt;/ion-label&gt;
          &lt;ion-input type="text" [(ngModel)]="matatu.matSacco"&gt;&lt;/ion-input&gt;
      &lt;/ion-item&gt;
  
      &lt;ion-item&gt;
          &lt;ion-label&gt;Driver&lt;/ion-label&gt;
          &lt;ion-input type="text" [(ngModel)]="matatu.matDriver"&gt;&lt;/ion-input&gt;
      &lt;/ion-item&gt;
  
      &lt;ion-item&gt;
            &lt;ion-label&gt; Access Code&lt;/ion-label&gt;
            &lt;ion-input type="password" [(ngModel)]="matatu.matAccessCode"&gt;&lt;/ion-input&gt;
      &lt;/ion-item&gt;
  
    &lt;/ion-list&gt;
    &lt;ion-list radio-group [(ngModel)]="matatu.matTracker"&gt;
      &lt;ion-list-header&gt;
        Preferred Tracking 
      &lt;/ion-list-header&gt;
  
      &lt;ion-item&gt;
          &lt;ion-label&gt;GPS&lt;/ion-label&gt;
          &lt;ion-radio checked="true" value="GPS"&gt;&lt;/ion-radio&gt;
      &lt;/ion-item&gt;
  
      &lt;ion-item&gt;
          &lt;ion-label&gt;Driver's Location&lt;/ion-label&gt;
          &lt;ion-radio value="Driver's Location"&gt;&lt;/ion-radio&gt;
      &lt;/ion-item&gt;
    &lt;/ion-list&gt;
  
    &lt;div padding&gt;
      &lt;button ion-button block (click)="editMatatu(matatu)"&gt;Save Changes&lt;/button&gt;
    &lt;/div&gt;
  &lt;/ion-content&gt;
  </code></pre>
  
  <p>
  How do I go about rectifying this? I'd appreciate it if it was pointed out to me where I went wrong, and what other approaches can get this done(even the dirty ones!).
  </p>