docs: function(encoded, key, model, overwrite)
    {
      if ( !isObject( encoded ) )
      {
        return model;
      }
  
      var db = this;
      var key = key || db.keyHandler.getKey( encoded, true );
  
      // The remote source might be crazy, if the key isn't there then log it and ignore it
      if ( !isValue( key ) )
      {
        Rekord.debug( Rekord.Debugs.MISSING_KEY, db, encoded );
  
        return;
      }
  
      var model = model || db.all[ key ];
      var decoded = db.decode( copy( encoded ) );
  
      // Reject the data if it's a lower revision
      if ( model )
      {
        var revisionRejected = this.revisionFunction( model, encoded );
  
        if ( revisionRejected )
        {
          Rekord.debug( Rekord.Debugs.SAVE_OLD_REVISION, db, model, encoded );
  
          return model;
        }
      }
  
      // If the model already exists, update it.
      if ( model )
      {
        if ( db.keyHandler.hasKeyChange( model, decoded ) )
        {
          key = model.$setKey( db.keyHandler.getKey( decoded, true ) );
        }
  
        db.addReference( model, key );
  
        if ( !model.$saved )
        {
          model.$saved = {};
        }
  
        var current = model; // model.$toJSON( true );
        var conflicts = {};
        var conflicted = false;
        var updated = {};
        var previous = {};
        var saved = {};
        var notReallySaved = isEmpty( model.$saved );
        var relations = db.relations;
        var compareTo = db.decode( model.$saved ); // model.$saved
  
        for (var prop in encoded)
        {
          if ( prop.charAt(0) === '$' )
          {
            continue;
          }
  
          if ( prop in relations )
          {
            model.$set( prop, encoded[ prop ], true );
  
            continue;
          }
  
          var currentValue = current[ prop ];
          var savedValue = compareTo[ prop ];
  
          previous[ prop ] = model[ prop ];
          saved[ prop ] = savedValue;
  
          if ( notReallySaved || overwrite || equals( currentValue, savedValue ) )
          {
            model[ prop ] = decoded[ prop ];
            updated[ prop ] = encoded[ prop ];
  
            if ( model.$local )
            {
              model.$local[ prop ] = encoded[ prop ];
            }
          }
          else
          {
            conflicts[ prop ] = encoded[ prop ];
            conflicted = true;
          }
  
          model.$saved[ prop ] = copy( encoded[ prop ] );
        }
  
        if ( conflicted )
        {
          model.$trigger( Model.Events.PartialUpdate, [encoded, updated, previous, saved, conflicts] );
        }
        else
        {
          model.$trigger( Model.Events.FullUpdate, [encoded, updated, previous, saved, conflicts] );
        }
  
        model.$trigger( Model.Events.RemoteUpdate, [encoded, updated, previous, saved, conflicts] );
  
        model.$addOperation( SaveNow );
  
        if ( !db.models.has( key ) )
        {
          db.saveReference( model, key );
          db.trigger( Database.Events.ModelAdded, [model, true] );
        }
      }
      // The model doesn't exist, create it.
      else
      {
        model = db.createModel( decoded, true );
  
        if ( model )
        {
          if ( db.cache === Cache.All )
          {
            model.$local = model.$toJSON( false );
            model.$local.$status = model.$status;
            model.$saved = model.$local.$saved = model.$toJSON( true );
  
            model.$addOperation( SaveNow );
          }
          else
          {
            model.$saved = model.$toJSON( true );
          }
        }
      }
  
      return model;
    }